Last active
October 15, 2015 15:57
-
-
Save kylieCat/4d5525fe50c37566ffa5 to your computer and use it in GitHub Desktop.
Git hook to append branch name to commit message
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
# Automatically adds the JIRA ticket number to the end of every commit message. | |
# This will work provided your branch is named in the form [a-zA-Z]{3}-[0-9]{3,} | |
# Place this file in PROJECT/.git/hooks and make it executable chmod +x path/to/file | |
# Example: | |
# [BND-1234] <--- This is a branch name | |
# $ git commit -am "This is my message" | |
# [BND-1234 1edab53] This is my message [BND-1234] | |
# | |
# [BND-1234-This-Branch-Has-A-Description] <--- This is a branch name | |
# $ git commit -am "This is my message" | |
# [BND-1234 1edab53] This is my message [BND-1234] | |
NAME=$(git branch | grep '*' | sed 's/* //' | grep -o '[a-zA-Z]\{3,\}-[0-9]\{3,\}') | |
echo $(cat "$1") "[$NAME]" > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment