Created
July 17, 2022 05:59
-
-
Save amirzenoozi/ed80483d33e5a71185f1cb3319525cb8 to your computer and use it in GitHub Desktop.
Check Commit Message Before Commit Change
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 | |
# Check This https://regex101.com/r/jkAuu3/1 | |
commit_regex='(((feat|fix|chore|refactor|style|test|docs)(((\w{0,15})))?))(:.\S.*)'; | |
error_msg="Aborting commit. Your commit message format is invalid, please check the references." | |
commit_message="$1"; | |
if ! grep -iqE "$commit_regex" "$commit_message"; | |
then | |
echo "$error_msg" >&2 | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment