Skip to content

Instantly share code, notes, and snippets.

@keithbro
Last active November 16, 2017 22:08
Show Gist options
  • Save keithbro/076f4f1856ab8727166a88a6ca5ac4dd to your computer and use it in GitHub Desktop.
Save keithbro/076f4f1856ab8727166a88a6ca5ac4dd to your computer and use it in GitHub Desktop.
Auto-append JIRA ticket codes from the branch name in to commit messages
# Put this in ~/.git-templates/hooks/commit-msg and re-init your git repo.
NAME=$(git branch | grep '* ' | grep -m 1 -o '[A-Z]\+-\d\+')
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$NAME" ] && [ -n "$TEXT" ]
then
echo $(cat "$1" | sed '/^#.*/d')' ['"$NAME"']' > "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment