Created
May 25, 2016 23:55
-
-
Save puneetar/b6e3b81e4fb218d7ebf2e76f49d73f0b to your computer and use it in GitHub Desktop.
git commit hook : file : commit-msg
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 adds branch name and branch description to every commit message. | |
# For eg : branch name : puneet/CHOW-142412-this-works | |
# will result into commit message : "CHOW-142412: this is my commit message" | |
# | |
#NAME=$(git branch | grep '*' | sed 's/* //') | |
NAME=$(git branch | grep '*' | sed 's/* \(.*\)\///' | sed 's/\([0-9]\)-.*/\1/') | |
DESCRIPTION=$(git config branch."$NAME".description) | |
echo "$NAME"': '$(cat "$1") > "$1" | |
if [ -n "$DESCRIPTION" ] | |
then | |
echo "" >> "$1" | |
echo $DESCRIPTION >> "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment