Skip to content

Instantly share code, notes, and snippets.

@jmaumene
jmaumene / commit-msg
Created Jul 31, 2020
Check git commit message format : <type>(<scope>) <Short summary>
View commit-msg
#!/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:"
@jmaumene
jmaumene / commit-msg
Last active Jul 31, 2020
Check git commit message format : <type>(<scope>) #00000 <Short summary>
View commit-msg
#!/usr/bin/env bash
# regex to validate in commit msg
commit_regex='^(feat|fix|docs|refactor|style|test|ci)\([a-z](-|[[:alnum:]]|[[:space:]])+\) #[[:digit:]]+ [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:"