Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git Hook to prepend a commit message with the Jira ticket id at the start of the current branch's name
#!/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
You can’t perform that action at this time.