Skip to content

Commit

Permalink
Don't generate superfluous output
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdb committed Aug 22, 2013
1 parent 355e698 commit 11d292c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions bin/git-branch-delete-orphans
Expand Up @@ -14,21 +14,14 @@ require 'rainbow'
end

def remotes
puts "Listing remote branches..."
@remote ||= `git ls-remote | grep 'refs/heads'`.split("\n").map { |l| l.gsub(/^.*refs\/heads\//, '').strip }
@remote ||= `git ls-remote -q | grep 'refs/heads'`.split("\n").map { |l| l.gsub(/^.*refs\/heads\//, '').strip }
end

def locals
@local ||= `cat .git/config | grep "refs/heads/\\w"`.split("\n").map { |l| l.gsub(/^.*refs\/heads\//, '').strip }
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}" }
Expand Down Expand Up @@ -66,7 +59,7 @@ if $?.success?
orphans = locals - remotes

# step 3: action the orphans
cli(orphans)
cli(orphans) unless orphans.empty?

else

Expand Down

0 comments on commit 11d292c

Please sign in to comment.