diff --git a/lefthook.yml b/lefthook.yml index 77a797709..119054b6e 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -16,14 +16,22 @@ # Per project policy (`--no-verify` is banned), prefer fixing the # finding over bypassing the hook. -# Reject tool attribution trailers. +# Commit messages. Commits are authored by the maintainer's git identity; +# a co-author trailer is only for a contributor whose work is in the +# commit, under their GitHub noreply address. A message is refused when it +# carries a "Generated with" / "Generated by" line, a "-Session:" +# trailer, or a co-author trailer with any other address. commit-msg: commands: - no-tooling-trailer: + message-trailers: run: | - if grep -qiE '^(Co-Authored-By:.*(claude|anthropic|copilot|gpt|gemini)|Claude-Session:|Generated with)' "{1}"; then - echo "ERROR: the commit message carries a tooling co-author trailer or session link." >&2 - echo "Project policy: commits are authored by the maintainer's git identity alone." >&2 + msg="{1}" + if grep -qiE '^[^[:alnum:]]*Generated (with|by)[[:space:]]' "$msg" || + grep -qiE '^[[:alpha:]]+-Session:' "$msg" || + grep -iE '^Co-authored-by:' "$msg" | + grep -qviE '<[^<>[:space:]]+@users\.noreply\.github\.com>[[:space:]]*$'; then + echo "ERROR: the commit message carries a generator line, a session trailer," >&2 + echo "or a co-author trailer without a GitHub noreply address." >&2 echo "Remove the offending line(s) from the message and commit again." >&2 exit 1 fi