Skip to content

Instantly share code, notes, and snippets.

View codesman's full-sized avatar

Tom Holland codesman

View GitHub Profile
@codesman
codesman / commit.msg.sample
Last active October 28, 2018 03:01
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