Skip to content

Instantly share code, notes, and snippets.

@StephaneTrebel
Last active August 11, 2017 07:48
Show Gist options
  • Save StephaneTrebel/fd9058735fb03935b64aef19077ddc69 to your computer and use it in GitHub Desktop.
Save StephaneTrebel/fd9058735fb03935b64aef19077ddc69 to your computer and use it in GitHub Desktop.
Automagically add the JIRA branch name to the commit message
#!/bin/sh
# Add "commitmsg": "./commitmsg.sh ${GIT_PARAMS}" to your package.json and use Husky to add it as a githook
TICKET=$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev | grep -o -E "[A-Z]+-[0-9]+")
if [ -n "${TICKET}" ]; then
# sed -e "1s/^/[${TICKET}] /" $1
echo -n "[$TICKET]"' '|cat - "$1" > /tmp/out && mv /tmp/out "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment