mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-21 18:33:36 +00:00
77766d6ee4
Long commit subjects and bullets are hard to read in narrow terminals and mailed logs. Contributors using `.githooks` via core.hooksPath now get an automatic guard in addition to the two-file pre-commit cap. - Add `.githooks/commit-msg` to fail when any message line exceeds 80 chars - Skip length checks while `.git/MERGE_HEAD` exists for merge commits - Sync AGENTS.md, README.md, CONTRIBUTING.md, and commit.prompt.md
33 lines
942 B
Bash
Executable File
33 lines
942 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Reject commit messages with any line longer than 80 characters.
|
|
# Enable with: git config core.hooksPath .githooks
|
|
#
|
|
# Merge commits often carry Git-generated "Merge branch …" lines that can
|
|
# exceed 80 columns when branch or remote names are long; skip the check then.
|
|
|
|
set -euo pipefail
|
|
|
|
msg_file=${1:?commit-msg hook requires path to message file}
|
|
|
|
if [[ -f .git/MERGE_HEAD ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
lineno=0
|
|
while IFS= read -r line || [[ -n "${line}" ]]; do
|
|
lineno=$((lineno + 1))
|
|
len=${#line}
|
|
if ((len > 80)); then
|
|
echo "❌ COMMIT MESSAGE: line ${lineno} is ${len} chars (max 80)"
|
|
echo ""
|
|
echo "Wrap the subject, summary, and bullets to 80 columns or fewer."
|
|
echo "See .github/prompts/commit.prompt.md"
|
|
echo ""
|
|
echo "Offending line (truncated for display):"
|
|
printf '%s\n' "${line}" | cut -c1-120
|
|
exit 1
|
|
fi
|
|
done <"${msg_file}"
|
|
|
|
exit 0
|