diff --git a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu index 04c8944..e9f872e 100644 --- a/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu +++ b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu @@ -102,7 +102,7 @@ export def "gm repo branch list" []: nothing -> table nothing { +export def "gm repo branch clean" []: nothing -> table { let dangling_branches = gm repo branch list | where remotes == [] if ($dangling_branches | is-empty) { @@ -110,14 +110,20 @@ export def "gm repo branch clean" []: nothing -> nothing { return } - for branch in $dangling_branches.branch { + $dangling_branches.branch | each { |branch| if $branch == (^git branch --show-current) { log warning $"($branch) is currently checked out and cannot be deleted" - continue + } else { + log info $"deleting branch `($branch)`" + let revision = ^git branch --delete --force $branch + | lines + | parse "Deleted branch {br} (was {rev})." + | into record + | get rev + | ^git rev-parse $in + + { name: $branch, revision: $revision } } - - log info $"deleting branch `($branch)`" - ^git branch --quiet --delete --force $branch } }