Skip to content

Instantly share code, notes, and snippets.

@PurpleBooth
Last active August 2, 2018 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleBooth/682daa8f5df10a120a027e6a19942344 to your computer and use it in GitHub Desktop.
Save PurpleBooth/682daa8f5df10a120a027e6a19942344 to your computer and use it in GitHub Desktop.
Ensure that your pivotal tracker story ID is in your commit message using a git commit-msg hook
#!/usr/bin/env bash
# Put this in ".git/hooks/commit-msg"
# and make it executable
# chmod a+x ".git/hooks/commit-msg"
set -euo pipefail
MSG="$1"
if ! grep -qE '\[(([Dd]elivers|[Ff]ixes|[Ff]inishes) #[0-9]+|(#[0-9]+))([ ,]#[0-9]+)?\]' "$MSG";then
cat "$MSG"
cat << EOF
Your commit message must contain the a pivotal tracker story id in the format [#4576346] somewhere in the message"
Examples:
[Delivers #12345678]
[fixes #12345678]
[finishes #12345678]
[#12345884 #12345678]
[#12345884,#12345678]
[#12345678],[#12345884]
This will address [#12345884]
EOF
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment