Created
August 15, 2012 13:57
-
-
Save AaronTorgerson/3360374 to your computer and use it in GitHub Desktop.
Ruby script to close old branches in a given repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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