Skip to content

Instantly share code, notes, and snippets.

@robertpostill
Created August 19, 2010 00:07
Show Gist options
  • Save robertpostill/536609 to your computer and use it in GitHub Desktop.
Save robertpostill/536609 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Shmaelessly ripped from http://www.robbyonrails.com/articles/2008/12/11/lighthouse-tickets-and-git-branching
#
# Will append the current pivotal tracker ticket number to the commit message automatically
# when you use the PT_* branch naming convention.
#
# Drop into .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
exec < /dev/tty
commit_message=$1
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
branch=${ref#refs/heads/}
if [[ $branch =~ PT_(.*) ]]
then
pivotal_ticket=${BASH_REMATCH[1]}
echo "What is the state of ticket #${pivotal_ticket}? "
echo "(o)pen "
echo "(f)ixed"
echo "Enter the current state for #${pivotal_ticket}: (o)"
state="open"
read state_selection
case $state_selection in
"o" )
state="open"
;;
"f" )
state="fixed"
;;
esac
echo >&2 "[#${pivotal_ticket} state:${state}]" >> "$1"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment