Skip to content

Instantly share code, notes, and snippets.

@AaronTorgerson
Created August 15, 2012 13:57
Show Gist options
  • Save AaronTorgerson/3360374 to your computer and use it in GitHub Desktop.
Save AaronTorgerson/3360374 to your computer and use it in GitHub Desktop.
Ruby script to close old branches in a given repo
#!/usr/bin/env ruby
Dir.chdir(ARGV[0])
raw_changeset_hashes = `hg log -r "head() and not(closed()) and not(date(-30)) and not outgoing()" --template "{node}\n"`
changeset_hashes = raw_changeset_hashes.split(/\n/)
if (changeset_hashes.length > 0)
changeset_hashes.each do | h |
if (system("hg up #{h}"))
system('hg ci --close-branch -m "Closed automatically. Last changeset aged past 30 days"')
system('hg nudge')
end
end
else
puts "Nothing to do"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment