Skip to content

Commit 91e72ae

Browse files
committed
grecent handle errors handling
- Skip removed files
1 parent a5fd6ea commit 91e72ae

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

gitfix.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SYNOPSIS
33
Git 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

grecent.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
}
3742
if (-not $selected) {
3843
Write-Warning "No user selection made, exiting."
3944
exit 0

0 commit comments

Comments
 (0)