Created
June 25, 2012 21:43
-
-
Save teddyzetterlund/2991476 to your computer and use it in GitHub Desktop.
Rename to pre_commit and put it in <your-project>/.git/hooks to require commits to follow policy
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 | |
# Compare commit message formatting to formatting policy. | |
# | |
# Message should include a Pivotal Story ID reference | |
# and an optional state change keyword. | |
# | |
# Example: [Fixes #12345] | |
message_file = ARGV[0] | |
message = File.read(message_file) | |
$actions = %w(fix fixes complete completes finish finishes) | |
$regex = /\[(#{$actions.join("|")})?\s?#(\d+)\]/i | |
if !$regex.match(message) | |
puts "[POLICY] Your message does not include a story ID" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment