sigit.io/.git-hooks/commit-msg

19 lines
684 B
Plaintext
Raw Normal View History

2024-08-06 14:01:54 +00:00
#!/bin/sh
# Get the commit message (the parameter we're given is just the path to the
# temporary file which holds the message).
commit_message=$(cat "$1")
if (echo "$commit_message" | grep -Eq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9 \-]+\))?!?: .+$") then
2024-08-06 14:14:48 +00:00
tput setaf 2;
echo "✔ Commit message meets Conventional Commit standards"
2024-08-06 14:14:48 +00:00
tput sgr0;
2024-08-06 14:01:54 +00:00
exit 0
fi
2024-08-06 14:14:48 +00:00
tput setaf 1;
echo "❌ Commit message does not meet the Conventional Commit standard!"
2024-08-06 14:14:48 +00:00
tput sgr0;
2024-08-06 14:01:54 +00:00
echo "An example of a valid message is:"
echo " feat(login): add the 'remember me' button"
echo "📝 More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary"
2024-08-06 14:01:54 +00:00
exit 1