Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.