Created
June 7, 2011 11:29
-
-
Save gorenje/1012062 to your computer and use it in GitHub Desktop.
commit-msg goes into .git/hooks/commit-msg (chmod 755)
This file contains 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/sh | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
ref=${ref#refs/heads/} | |
# allow for branch names: | |
# tick12+12_fubar | |
# tick12+12-fubar_sd | |
# ticket12+12-fubar_sd | |
# ticket12+12+123-fubar_sd | |
# or tick(et) replaced by issue (redmine conform) | |
# issue12+12 | |
# etc. | |
tick_num=$(echo "$ref" | gawk '// { match($0,"(issue|tick(et)?)[_]?([0-9+]+)",a); gsub( "+", " ", a[3]); printf a[3]; }') | |
if [ "$(cat $1 | grep -v ^#)" == "" ] ; then | |
# commit message completely empty, commit should be aborted. | |
exit 0 | |
fi | |
if [ "$tick_num" != "" ] ; then | |
echo "" >> $1 | |
for n in $tick_num ; do | |
echo "refs #"${n} >> $1 | |
done | |
fi | |
echo "" >> $1 | |
echo "On branch: ${ref}" >> $1 | |
echo "" >> $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment