Created
April 19, 2013 17:55
-
-
Save jacaetevha/5422000 to your computer and use it in GitHub Desktop.
This file contains 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
[__TICKET_NUMBER__] |
This file contains 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
git config commit.template path/to/.gitmessage.txt |
This file contains 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 | |
# | |
# Called by "git commit" with the | |
# name of the file that has the | |
# commit message, followed by | |
# the description of the commit | |
# message's source. The hook's | |
# purpose is to edit the commit | |
# message file. If the hook fails | |
# with a non-zero status, | |
# the commit is aborted. | |
# | |
message_file = ARGV[0] | |
message = File.read(message_file) | |
pivotal_task_number = `git rev-parse --abbrev-ref HEAD | grep --only-matching '[0-9]*$'`.strip | |
replacement_text = pivotal_task_number.length == 0 ? 'NOTICKET' : "##{pivotal_task_number}" | |
File.open(message_file, 'w') { |f| f.write message.sub('__TICKET_NUMBER__', replacement_text) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment