Last active
December 18, 2015 14:38
-
-
Save jimjh/5798168 to your computer and use it in GitHub Desktop.
Git hook for Pivotal Tracker
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
#!/bin/bash | |
prepend () | |
{ | |
# extract branch name | |
branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
# extract story ID | |
[[ ${branch_name} =~ ^(chore|feature|bug)\/X([[:digit:]]+)$ ]] && sed -i '' '1i\ | |
'"[#${BASH_REMATCH[2]}] " "$1" | |
} | |
case "$2" in | |
template) # exclude templates, merges, squashes | |
;; | |
merge) | |
;; | |
squash) | |
;; | |
*) | |
if [ -z "$3" ]; then # exclude amends | |
prepend $1 | |
fi | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment