#!/bin/bash # Commit message hook: validate commit message format COMMIT_MSG_FILE=$1 MSG=$(head -n1 "$COMMIT_MSG_FILE") # Skip validation for merge commits if echo "$MSG" | grep -q "^Merge"; then exit 0 fi # Check message length if [ ${#MSG} -lt 5 ]; then echo "❌ Commit message too short (min 5 characters)" exit 1 fi # Optional: enforce conventional commits format # Uncomment if you want to enforce prefixes like "feat:", "fix:", etc. # if ! echo "$MSG" | grep -qE "^(feat|fix|docs|style|refactor|test|chore|backend|frontend|deploy)(\(.+\))?:"; then # echo "❌ Commit message should follow format: type: description" # echo " Allowed types: feat, fix, docs, style, refactor, test, chore, backend, frontend, deploy" # exit 1 # fi echo "✅ Commit message OK" exit 0