Created
May 14, 2013 14:46
-
-
Save thejspr/5576495 to your computer and use it in GitHub Desktop.
Revisions
-
thejspr created this gist
May 14, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/usr/bin/env ruby # put this in .git/hooks/prepare-commit-msg message_file = ARGV[0] message = File.read(message_file) pivotal_story_number = `git rev-parse --abbrev-ref HEAD | grep --only-matching '[0-9]*$'`.strip # do not add anything if the branch doesn't have a story number or the message already contains one. unless pivotal_story_number.empty? || message =~ /^\[#\d+\]/ message = "[##{pivotal_story_number}]\n#{message}" end File.open(message_file, 'w') { |f| f.write(message) }