Created
December 19, 2012 00:34
-
-
Save garaemon/4333414 to your computer and use it in GitHub Desktop.
git commit-msg hook to insert ticket number to the comments of the commits automatically
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 | |
BRANCH=$(git symbolic-ref HEAD) | |
grep '^refs #[0-9]\+: ' $1 | |
if [ $? -eq 0 ]; then | |
exit | |
fi | |
ISSUE=$(echo $BRANCH | sed -e 's/^.*-id-\([0-9]*\)$/#\1/') | |
if [ "$ISSUE" != "$BRANCH" ]; then | |
echo "Auto append: $ISSUE" | |
mv $1 $1.$$ | |
echo -n "$ISSUE: " > $1 | |
cat $1.$$ >> $1 | |
rm $1.$$ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment