-
-
Save logicaroma/5f3087d4275934eca2f5 to your computer and use it in GitHub Desktop.
Git commit-msg hook to validate for jira issue or the word merge
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 | |
develop_branch="develop" | |
current_branch="$(git rev-parse --abbrev-ref HEAD)" | |
# regex to validate in commit msg | |
commit_regex='(wap-\d+|merge)' | |
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-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