Skip to content

Instantly share code, notes, and snippets.

@pbstriker38
Created May 10, 2018 20:54
Show Gist options
  • Select an option

  • Save pbstriker38/7abf38121096e7983cd884eca741a83d to your computer and use it in GitHub Desktop.

Select an option

Save pbstriker38/7abf38121096e7983cd884eca741a83d to your computer and use it in GitHub Desktop.
Add JIRA ticket to commit message
#!/bin/sh
BRANCH_NAME=$(git symbolic-ref --short HEAD)
TICKET_NUMBER=$(echo $BRANCH_NAME | egrep -o "[A-Z]+[_-]\d+$" | tr '_' '-')
if [[ -n $TICKET_NUMBER ]]; then
sed -i -e "1s/^/$TICKET_NUMBER /" $1
fi
@pbstriker38
Copy link
Copy Markdown
Author

Place in project_name/.git/hooks
You will probably need to run chmod +x prepare-commit-msg to make it executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment