Skip to content

Instantly share code, notes, and snippets.

@thanosp
Last active October 5, 2016 09:29
Show Gist options
  • Save thanosp/df44a55e11b75010d2c369a334b62566 to your computer and use it in GitHub Desktop.
Save thanosp/df44a55e11b75010d2c369a334b62566 to your computer and use it in GitHub Desktop.
.git/hooks/commit-msg for JIRA branch
#!/bin/sh
#
[[ -n "$(cat $1 | grep 'fixup!')" ]] && FIXUP="YES"
JIRA_PREFIX="CSB-"
TICKET=$JIRA_PREFIX$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev | grep -o -E "[0-9]+" | head -n1)
if [[ "" != "`head -n1 $1`" && -n "${TICKET}" && -z "${FIXUP}" ]]; then
sed -i.bak -e "1s/^/[${TICKET}] /" $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment