Skip to content

Instantly share code, notes, and snippets.

@jimjh
Last active December 18, 2015 14:38
Show Gist options
  • Save jimjh/5798168 to your computer and use it in GitHub Desktop.
Save jimjh/5798168 to your computer and use it in GitHub Desktop.
Git hook for Pivotal Tracker
#!/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