Skip to content

Instantly share code, notes, and snippets.

@alice1017
Created July 10, 2014 02:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alice1017/2161e8ec1e75de1fbd9b to your computer and use it in GitHub Desktop.
The prepare commit msg hook script of git, Add issue number to commit message when branch name starts with "Fix"
#!/bin/sh
if [ -n "$1" ]
then
mv $1 $1.tmp
issue_branch=$(git branch | cat | grep "*" | awk '{print $2}' | cut -c 1-3);
if [ $issue_branch="Fix" ]
then
issue_num=$(git branch | cat | grep "*" | awk '{print $2}' | cut -c 4-);
echo "[$issue_num]: " > $1;
cat $1.tmp >> $1;
rm $1.tmp;
fi
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment