File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22. SYNOPSIS
33Git fixup commit to a previous commit, selected interactively via fzf.
44. DESCRIPTION
5- Stages all changes, lets you pick a past commit via fzf, then runs:
5+ Using staged or all-unstaged changes, lets you pick a past commit via fzf, then runs:
66 git commit --fixup <sha>
77 git rebase --autosquash <sha>~1
88. LINK
Original file line number Diff line number Diff line change @@ -25,15 +25,20 @@ if (-not $allFiles) {
2525 throw " No changed files found."
2626}
2727
28- $fileInfos = $allFiles | ForEach-Object {
28+ $fileInfos = $allFiles | Where-Object { Test-Path - LiteralPath $_ } | ForEach-Object {
2929 [pscustomobject ]@ {
3030 OrigPath = $_
3131 LastWriteTime = (Get-Item - Force - LiteralPath $_ ).LastWriteTime # MAYBE fix this to work when in a subdir
3232 }
3333} | Sort-Object LastWriteTime - Descending
3434
3535$FORMAT = ' yyyy-MM-dd HH:mm'
36- $selected = $fileInfos | ForEach-Object { " $ ( $_.LastWriteTime.ToString ($FORMAT )) $ ( $_.OrigPath ) " } | fzf -- no- sort -- layout= reverse
36+ try {
37+ $selected = $fileInfos | ForEach-Object { " $ ( $_.LastWriteTime.ToString ($FORMAT )) $ ( $_.OrigPath ) " } | fzf -- no- sort -- layout= reverse
38+ } catch [System.Management.Automation.NativeCommandExitException ] {
39+ Write-Warning " No user selection made, exiting."
40+ exit 0
41+ }
3742if (-not $selected ) {
3843 Write-Warning " No user selection made, exiting."
3944 exit 0
You can’t perform that action at this time.
0 commit comments