Skip to content

Instantly share code, notes, and snippets.

@kyhule
Created December 3, 2015 12:27
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 kyhule/df0cabd29df5a3f9062a to your computer and use it in GitHub Desktop.
Save kyhule/df0cabd29df5a3f9062a to your computer and use it in GitHub Desktop.
Git hook for verify Jira ticket in commit message
#!/usr/bin/env bash
# set this to your active development branch
current_branch="$(git rev-parse --abbrev-ref HEAD)"
# regex to validate in commit msg
commit_regex='(DEMO-\d+|merge)'
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('DEMO-1111') or 'Merge'"
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment