Created
June 19, 2020 11:06
-
-
Save manoj2411/c93a4dff1dbebb460f0f68d70741c275 to your computer and use it in GitHub Desktop.
Checks git message every time and ensure that the message is starting with the defined format. Useful where you need Jira-ID or something similar in start of the 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
#!/bin/sh | |
# | |
# save this file with this name and mark it executable `chmod +x .git/hooks/commit-msg` | |
commit_desired_format='(ZA-\d+|GH-\d+|merge)' | |
error_msg="Aborting commit. Commit message is missing ('ZA-XXX') or ('GH-XXX') or 'merge'" | |
if ! grep -iqE "$commit_desired_format" "$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