diff --git a/.githooks/commit-msg b/.githooks/commit-msg index a08b041..3543f09 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -27,7 +27,7 @@ while IFS= read -r line || [[ -n "${line}" ]]; do if ((len > 80)); then echo "❌ COMMIT MESSAGE: line ${lineno} is ${len} chars (max 80)" echo "" - echo "Required layout: subject, blank, summary paragraph, blank, bullets." + echo "Required: subject, blank, summary, blank, then \"- ...\" bullets." echo "See .github/prompts/commit.prompt.md" echo "" echo "Offending line (truncated for display):" @@ -40,7 +40,7 @@ done <"${msg_file}" # Drop trailing empty lines so optional final newline does not confuse counts. while ((${#lines[@]} > 0)); do last=$(( ${#lines[@]} - 1 )) - if [[ -z ${lines[last]} ]]; then + if [[ -z "${lines[last]}" ]]; then unset "lines[last]" else break @@ -49,8 +49,8 @@ done n=${#lines[@]} if ((n < 5)); then - echo "❌ COMMIT MESSAGE: need subject, blank, summary, blank, then bullets" - echo "(at least five lines). See .github/prompts/commit.prompt.md" + echo "❌ COMMIT MESSAGE: need subject, blank, summary, blank, bullets" + echo "(five or more lines). See .github/prompts/commit.prompt.md" exit 1 fi @@ -81,8 +81,8 @@ if ((bullet_idx < 0)); then fi if ((bullet_idx < 3)); then - echo "❌ COMMIT MESSAGE: add at least one summary line after the subject blank" - echo "before the separator blank and bullets." + echo "❌ COMMIT MESSAGE: add a summary line after the subject blank line" + echo "before the blank that precedes bullets." exit 1 fi @@ -96,9 +96,8 @@ has_summary=0 for ((i = 2; i < bullet_idx - 1; i++)); do line=${lines[i]} if [[ -n "${line}" ]] && [[ "${line}" =~ ^[[:space:]]*-[[:space:]] ]]; then - echo "❌ COMMIT MESSAGE: line $((i + 1)) looks like a bullet but is above" - echo "the summary block; write prose summary lines first, then a blank" - echo "line, then \"- ...\" bullets." + echo "❌ COMMIT MESSAGE: summary line $((i + 1)) starts like a bullet" + echo "Use prose first, one blank line, then hyphen bullets." exit 1 fi if [[ -n "${line}" ]]; then @@ -107,22 +106,21 @@ for ((i = 2; i < bullet_idx - 1; i++)); do done if ((has_summary == 0)); then - echo "❌ COMMIT MESSAGE: summary paragraph is empty (need 1–3 sentences before" - echo "the blank line that precedes bullets)." + echo "❌ COMMIT MESSAGE: summary paragraph is empty before the bullet list" + echo "Add one to three sentences, then a blank line, then bullets." exit 1 fi for ((i = bullet_idx; i < n; i++)); do line=${lines[i]} if [[ -z "${line}" ]]; then - echo "❌ COMMIT MESSAGE: line $((i + 1)) is empty inside the bullet block;" - echo "remove blank lines between bullets or end the message after the last" - echo "bullet." + echo "❌ COMMIT MESSAGE: empty line $((i + 1)) inside bullet block" + echo "Remove blanks between bullets or end after the last bullet." exit 1 fi if ! [[ "${line}" =~ ^[[:space:]]*-[[:space:]] ]]; then - echo "❌ COMMIT MESSAGE: line $((i + 1)) must be a \"- ...\" bullet after the" - echo "summary section." + echo "❌ COMMIT MESSAGE: line $((i + 1)) is not a hyphen bullet" + echo "Each bullet line must start with dash then space after summary." exit 1 fi done