1#!/bin/sh 2 3# Sample Pit integration hook. 4# 5# 1. Appends Pit task number to the commit message when you use 6# task number as your git branch name. 7# 8# 2. Lets you specify task status and updates it in Pit accordingly. 9# 10# 3. Creates task note with the complete commit massage. 11# 12# Drop into .git/hooks/commit-msg 13# chmod +x .git/hooks/commit-msg 14 15pit="/usr/local/bin/pit" 16exec < /dev/tty 17 18ref=$(git symbolic-ref HEAD 2> /dev/null) || return 19branch=${ref#refs/heads/} 20 21if [[ $branch =~ ^([0-9]+)$ ]] 22then 23 pit_task=${BASH_REMATCH[1]} 24 25 echo "What is the status of task ${pit_task}?" 26 echo " (I)n progress" 27 echo " (P)ostponed" 28 echo " (O)pen" 29 echo " (D)one" 30 echo "Enter the status for task ${pit_task} [D]: " 31 read selection 32 33 status="done" 34 case $selection in 35 'i'|'I' ) 36 status="in progress" 37 ;; 38 'p'|'P' ) 39 status="postponed" 40 ;; 41 'o'|'O' ) 42 status="open" 43 ;; 44 esac 45 46 commit="`grep -v "^#" $1`" 47 append="[task ${pit_task}, status:${status}]" 48 echo >&2 "$append" >> "$1" 49 "${pit}" task -e "${pit_task}" -s "${status}" 50 "${pit}" note -c "${commit} ${append}" 51 exit 0 52fi 53