Files
ai-for-dummies/.husky/commit-msg
Marcos Paulo 7896b634a8 fix: allow revert: in the commit-msg type list
Standard conventional type, missing from the regex.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 03:43:23 +00:00

27 lines
969 B
Plaintext

# Conventional commits, matching this repository's existing log
# (feat:, fix:, docs:, refactor:, chore:, test:, style:, ci:).
#
# Deliberately a plain regex rather than a commitlint dependency: this project's
# thesis is having no unnecessary dependencies, and one regex is legible to
# every agent that has to satisfy it.
message_file=$1
first_line=$(head -n1 "$message_file")
# Allow merge and revert commits through untouched.
case "$first_line" in
"Merge "*|"Revert "*) exit 0 ;;
esac
if ! printf '%s' "$first_line" | grep -qE '^(feat|fix|docs|refactor|chore|test|style|ci|perf|build|revert)(\([a-z0-9 -]+\))?: .{1,}$'; then
echo "commit-msg: subject must be '<type>: <subject>' (lowercase type)." >&2
echo " types: feat fix docs refactor chore test style ci perf build revert" >&2
echo " got: $first_line" >&2
exit 1
fi
if [ "${#first_line}" -gt 72 ]; then
echo "commit-msg: subject is ${#first_line} chars; keep it under 72." >&2
exit 1
fi