Last active
November 16, 2017 22:08
-
-
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
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
# 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