Created
March 26, 2019 09:12
-
-
Save perchrh/3b6cc50e2ae8891e9177885cd916adaa to your computer and use it in GitHub Desktop.
.git/hooks/commit-msg for verifiying Jira id is present in commit message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# set this to your active development branch | |
# based on https://gist.github.com/pgilad/5d7e4db725a906bd7aa7 | |
develop_branch="develop" | |
current_branch="$(git rev-parse --abbrev-ref HEAD)" | |
# regex to validate in commit msg | |
commit_regex='(VUDDF-[0-9]+|merge)' | |
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('VUDDF-1111') or 'Merge'" | |
# only check commit messages on main development branch | |
[ "$current_branch" != "$develop_branch" ] && exit 0 | |
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