MSG_FILE="$1"
MSG=$(head -1 "$MSG_FILE")
if echo "$MSG" | grep -qE "^Merge |^Revert "; then
exit 0
fi
PATTERN="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-z0-9_-]+\))?\!?: .+"
if ! echo "$MSG" | grep -qE "$PATTERN"; then
echo "commit-msg: ERROR — commit message does not follow Conventional Commits format."
echo ""
echo " Expected: <type>[(scope)][!]: <description>"
echo ""
echo " Types: feat fix docs style refactor perf test build ci chore revert"
echo " Breaking: add ! before colon, e.g. feat!: remove old API"
echo ""
echo " Your message: $MSG"
exit 1
fi