This file contains 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
printf '#!/bin/sh\n | |
# Get the commit message | |
commit_message=$(cat "$1")\n | |
# Regular expression pattern for conventional commits | |
pattern='\''^(feat|fix|docs|style|refactor|test|chore)(\([a-z0-9-]+\))?!?: [^\s].{0,100}$'\''\n | |
# Check if the commit message matches the pattern | |
if echo "$commit_message" | grep -qE "$pattern"; then | |
\techo "Commit message is compliant with conventional commits." | |
else | |
\techo "Commit message is not compliant with conventional commits. See https://www.conventionalcommits.org/en/v1.0.0/#summary"; exit 1 |