Created
July 13, 2018 10:30
-
-
Save venkatasykam/ed8d73eda6d27e66af8a11fc8f2b34bd to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
get_clean_message() { | |
egrep -o '^[^#].*' "$1" | |
} | |
# Do not allow empty messages after removing comments | |
[ -z "$(get_clean_message "$1")" ] && { | |
echo >&2 Commit message can NOT be empty. | |
exit 1 | |
} | |
# regex to validate in commit msg | |
commit_regex='(wap-[0-9]+|merge)' | |
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('WAP-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
This is validating the commit message which we made in local git repo. ( need to install & check this in git server side)
git commit -m “”
git commit -m “updating changes”
git commit -m “updating changes WAP-123”
If this is useful, you can update the script as per your requirement.