Created
December 3, 2010 06:51
-
-
Save nishimura/726661 to your computer and use it in GitHub Desktop.
Add issue id to commit message.
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) | |
if [ "$BRANCH" == "refs/heads/master" ]; then | |
echo "cannot commit on master branch." | |
echo "please commit on topic branch." | |
exit 1 | |
fi | |
grep '^refs #[0-9]\+: ' $1 | |
if [ $? -eq 0 ]; then | |
exit | |
fi | |
ISSUE=$(echo $BRANCH | sed -e 's/^.*-id-\([0-9]\+\)$/refs #\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