Created
September 15, 2011 13:46
-
-
Save jens/1219260 to your computer and use it in GitHub Desktop.
Get story id from branch name and add pivotal reference to commit message
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 | |
# | |
# Copy this file into .git/hooks and chmod +x | |
# | |
branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1].to_s | |
PIVOTAL_REFERENCE = /s-(\d+)/i | |
if story_match = branchname.match(PIVOTAL_REFERENCE) | |
story_id = story_match.captures.first | |
reference = "[#%s]" % story_id | |
`echo "#{reference}"|cat - #{ARGV[0]} > /tmp/out && mv /tmp/out #{ARGV[0]}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment