Skip to content

Instantly share code, notes, and snippets.

@5470x3
Created August 9, 2015 22:40
Show Gist options
  • Save 5470x3/37e0e40d1d4da6a4e175 to your computer and use it in GitHub Desktop.
Save 5470x3/37e0e40d1d4da6a4e175 to your computer and use it in GitHub Desktop.
.git/hooks/prepare-commit-msg
#!/bin/sh
BRANCHNAME=`git branch | grep '*' | grep "[A-Z]\+-[0-9]\+" | cut -d' ' -f2`
if [ $(cat $1 | grep -e "^${BRANCHNAME}">/dev/null;echo $?) -eq 0 ] ; then exit 0;
elif [ $(echo $2 | grep -e "^message">/dev/null; echo $?) -eq 0 -o $2=="" ]; then
mv $1 $1.tmp
echo ${BRANCHNAME}> $1
cat $1.tmp >> $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment