Skip to content

Instantly share code, notes, and snippets.

@jmaumene
jmaumene / commit-msg
Created July 31, 2020 22:00
Check git commit message format : <type>(<scope>) <Short summary>
#!/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 July 31, 2020 21:58
Check git commit message format : <type>(<scope>) #00000 <Short summary>
#!/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:"