Skip to content

Instantly share code, notes, and snippets.

@peterdemin
Created December 29, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterdemin/a7b6825b2be70112d54ffcad695465da to your computer and use it in GitHub Desktop.
Save peterdemin/a7b6825b2be70112d54ffcad695465da to your computer and use it in GitHub Desktop.
Git commit-msg hook, that adds Jira ticket number from branch name to each commit message
#!/bin/sh
ticket=$(git symbolic-ref HEAD | grep -o 'ND-[0-9][0-9]*')
if [ -n "${ticket}" ]; then
grep -qs "^ *${ticket}" "${1}" || (echo >> "${1}" && echo "${ticket}" >> "${1}")
fi
@peterdemin
Copy link
Author

This one parses Jira ticket numbers in a form of ND-<number>. Adapt to your needs

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