Skip to content

Instantly share code, notes, and snippets.

@codesman
Last active October 28, 2018 03:01
Show Gist options
  • Save codesman/d36360f100fe3b64ad30fa88dfc8e6f8 to your computer and use it in GitHub Desktop.
Save codesman/d36360f100fe3b64ad30fa88dfc8e6f8 to your computer and use it in GitHub Desktop.
Git Hook to prepend Ticket Number to Commit Message
#!/bin/bash
# JIRA Ticket Number will be prepended to message when running git commit
# Only on branches that have a ticket number
TICKET_NUMBER=$(git symbolic-ref --short HEAD | grep -o '[A-Z]\+-[0-9]\+')
MESSAGE=`cat $1`
if [ ! -z "${TICKET_NUMBER}" -a "${TICKET_NUMBER}" != " " ]; then
echo "${TICKET_NUMBER} ${MESSAGE}" > "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment