# 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)(\([a-z0-9 -]+\))?: .{1,}$'; then echo "commit-msg: subject must be ': ' (lowercase type)." >&2 echo " types: feat fix docs refactor chore test style ci perf build" >&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