Skip to content

Instantly share code, notes, and snippets.

@veewee
Last active June 25, 2022 15:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save veewee/939539fef7953bd11cdb to your computer and use it in GitHub Desktop.
Save veewee/939539fef7953bd11cdb to your computer and use it in GitHub Desktop.
Enforce the JIRA issue number in a GIT commit message
#!/bin/sh
# This hook will make sure that the commit message contains a JIRA issue.
#
# To enable this hook, rename this file to ".git/hooks/commit-msg".
# Make sure to add execution permissions to the file.
export MESSAGE=$(<$1)
export JIRA_ISSUE_TAG='ISSUETAG-([0-9]*)'
if [[ $MESSAGE =~ $JIRA_ISSUE_TAG ]]; then
echo -e "\e[32mGreat, your commit message contains a JIRA issue!\e[0m"
exit 0;
fi
echo -e "\e[31mOh hamburgers ... You forgot to add a JIRA issue number!\e[0m";
exit 1;
@asfandyar-malik
Copy link

Thanks

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