Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2023 07:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Conventional Commits Git Hook
commit_msg=$(cat $commit_msg_file)
# Define the pattern for conventional commit messages
pattern="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.+\))?: .+"
if [[ ! ${commit_msg} =~ $pattern ]]; then
echo "ERROR: The commit message does not follow the conventional commit format."
echo "Valid types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test"
echo "Format: type(scope): subject"
exit 1
# If commit message matches the pattern, continue with the commit
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment