Created
March 4, 2014 18:30
-
-
Save jbueza/9352607 to your computer and use it in GitHub Desktop.
Automatically add branch name and branch description to every commit message except merge commit.
This file contains 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/sh | |
# | |
# Automatically add branch name and branch description to every commit message except merge commit. | |
# | |
COMMIT_EDITMSG=$1 | |
addBranchName() { | |
NAME=$(git branch | grep '*' | sed 's/* //') | |
DESCRIPTION=$(git config branch."$NAME".description) | |
echo "[$NAME]: $(cat $COMMIT_EDITMSG)" > $COMMIT_EDITMSG | |
if [ -n "$DESCRIPTION" ] | |
then | |
echo "" >> $COMMIT_EDITMSG | |
echo $DESCRIPTION >> $COMMIT_EDITMSG | |
fi | |
} | |
MERGE=$(cat $COMMIT_EDITMSG|grep -i 'merge'|wc -l) | |
if [ $MERGE -eq 0 ] ; then | |
addBranchName | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment