mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-10-02 14:23:58 +00:00
chore(githooks): add commit-msg hook for 80-column messages
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
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user