From e8c84da28474df0aeac46acfb1eca8bf425d17f9 Mon Sep 17 00:00:00 2001 From: Wayne Moore Date: Sun, 3 Jun 2012 19:08:18 +0100 Subject: [PATCH 1/2] Now works with ruby 1.9 --- bin/git-branch-delete-orphans | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git-branch-delete-orphans b/bin/git-branch-delete-orphans index fc52b21..7b9a2e2 100755 --- a/bin/git-branch-delete-orphans +++ b/bin/git-branch-delete-orphans @@ -2,11 +2,11 @@ def remotes puts "Listing remote branches..." - @remote ||= `git ls-remote | grep 'refs/heads'`.map { |l| l.gsub(/^.*refs\/heads\//, '').strip } + @remote ||= `git ls-remote | grep 'refs/heads'`.split("\n").map { |l| l.gsub(/^.*refs\/heads\//, '').strip } end def locals - @local ||= `cat .git/config | grep "refs/heads/\\w"`.map { |l| l.gsub(/^.*refs\/heads\//, '').strip } + @local ||= `cat .git/config | grep "refs/heads/\\w"`.split("\n").map { |l| l.gsub(/^.*refs\/heads\//, '').strip } end def cli(orphans) From e2a22678b461224d7ca5d89318d70b9a7e3e2d3c Mon Sep 17 00:00:00 2001 From: Wayne Moore Date: Mon, 4 Jun 2012 08:22:35 +0100 Subject: [PATCH 2/2] Improved usability. Will now let the user know when there is nothing to do. --- bin/git-branch-delete-orphans | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/git-branch-delete-orphans b/bin/git-branch-delete-orphans index 7b9a2e2..8bbc018 100755 --- a/bin/git-branch-delete-orphans +++ b/bin/git-branch-delete-orphans @@ -11,6 +11,12 @@ end def cli(orphans) puts "" + + if orphans.empty? + puts "No orphaned local branches, nothing to do." + exit + end + puts "The following branches track a remote branch which does not exist anymore:" orphans.each { |b| puts " - #{b}" }