Last active
May 31, 2019 00:54
-
-
Save bradparker/d8ad5c1554a600109e9ccc3318b912b7 to your computer and use it in GitHub Desktop.
Git Hook to prepend a commit message with the Jira ticket id at the start of the current branch's name
This file contains hidden or 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
#!/usr/bin/env bash | |
branchname=$(git branch | grep ^* | sed 's/\* //g') | |
regex="([A-Z]*-[0-9]*)" | |
if [[ $branchname =~ $regex ]] | |
then | |
ticket_id="${BASH_REMATCH[1]}" | |
message=`cat $1` | |
if [[ $message == $ticket_id* ]] || [[ $message == "fixup! "* ]] | |
then | |
exit | |
fi | |
echo "$ticket_id $message" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment