Skip to content

Instantly share code, notes, and snippets.

@puneetar
Created May 25, 2016 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puneetar/b6e3b81e4fb218d7ebf2e76f49d73f0b to your computer and use it in GitHub Desktop.
Save puneetar/b6e3b81e4fb218d7ebf2e76f49d73f0b to your computer and use it in GitHub Desktop.
git commit hook : file : commit-msg
#!/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