Created
July 31, 2020 22:00
-
-
Save jmaumene/599b16656eb4d4d8453bf02709d36c3f to your computer and use it in GitHub Desktop.
Check git commit message format : <type>(<scope>) <Short summary>
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 | |
# regex to validate in commit msg | |
commit_regex='^(feat|fix|docs|refactor|style|test|ci)\([a-z](-|[[:alnum:]]|[[:space:]])+\) [A-Z]' | |
if ! grep -E "$commit_regex" "$1"; then | |
echo "" | |
echo -e "\033[0;31m[POLICY] Your message is not formatted correctly!\033[0m" >&2 | |
echo "" | |
echo "Message format must be like:" | |
echo "<type>(<scope>) <Short summary>" | |
echo " " | |
echo "Commit Type: feat|fix|docs|refactor|style|test|ci lowercase" | |
echo "(Scope): Name of module / package / scope. Start with lowercase and after accept : space - a-z A-Z 0-9" | |
echo "Summary : Short tile. Start with UpperCase" | |
echo "" | |
echo "---------------------------" | |
grep -v '^#' "$1" | |
echo "---------------------------" | |
echo "" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment