Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created January 7, 2015 19:00
Show Gist options
  • Save toast38coza/890ad14bea5e0d47cf14 to your computer and use it in GitHub Desktop.
Save toast38coza/890ad14bea5e0d47cf14 to your computer and use it in GitHub Desktop.
Require that git commit messages contain a Pivotal ID
#!/usr/bin/python
import re, sys
message_file = sys.argv[1]
f = open(message_file)
message = f.read()
p = re.compile('^\[\#\d+\]')
if p.match(message) is None:
print "This commit needs a pivotal story ID. e.g.: git commit -am'[#82695812] - message goes here .. ' where 82695812 is your pivotal story ID"
sys.exit(1)
@toast38coza
Copy link
Author

Simply put this file in .git/hooks/prepare-commit-msg and then, if you try make a commit without including your Pivotal Tracker story ID you will get an error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment