Skip to content

Commit

Permalink
Run script at top level of git repo
Browse files Browse the repository at this point in the history
This fixes two issues: (1) running the script **outside** a git repo,
and (2) running the script in a subdirectory of a git repo, instead of
running it at the top level of the repo
  • Loading branch information
pvdb committed Apr 16, 2013
1 parent 436bfee commit 777aa05
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions bin/git-branch-delete-orphans
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,23 @@ def cli(orphans)
end
end

orphans = locals - remotes
cli(orphans)
git_dir = `git rev-parse --git-dir`.chomp

if $?.success?

# step 1: change to the root of the git repo
Dir.chdir File.dirname(git_dir)

# step 2: calculate the orphaned branches
orphans = locals - remotes

# step 3: action the orphans
cli(orphans)

else

puts "Please run #{File.basename __FILE__} from inside a git repo"

end

# That's all, Folks!

0 comments on commit 777aa05

Please sign in to comment.