Created
June 11, 2013 00:18
-
-
Save brendanjerwin/5753602 to your computer and use it in GitHub Desktop.
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 | |
# | |
# 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 "[ #{replacement_text}] - " + message } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment