From 7bcd28569189858a493227696e5479c577d72368 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:34 +0100 Subject: feat(git): pre-push checks Co-authored-by trailers for agents Same substring blacklist (copilot, claude, codex, ...) is now also applied to every Co-authored-by trailer in the commit message, not just the author header. Agents commonly slip in via that route. Trailers extracted with %(trailers:key=Co-authored-by,valueonly, unfold,separator=%x1f) and split in awk on \037, which can't appear in identity strings, so the tab-delimited record format stays unambiguous. To fix a flagged trailer use git commit --amend / interactive rebase to drop the Co-authored-by line; --reset-author won't help here. --- dot_config/git/hooks/executable_pre-push | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'dot_config/git/hooks') diff --git a/dot_config/git/hooks/executable_pre-push b/dot_config/git/hooks/executable_pre-push index a57e2d5..ba7dc60 100755 --- a/dot_config/git/hooks/executable_pre-push +++ b/dot_config/git/hooks/executable_pre-push @@ -58,11 +58,12 @@ while read -r _local_ref local_sha remote_ref remote_sha; do fi # One pass: per-commit emit - # SHA \t %G? \t cn \t ce \t an \t ae \t subject - # Tabs aren't valid in identity fields, so awk -F'\t' parses - # unambiguously. + # SHA \t %G? \t cn \t ce \t an \t ae \t co-authored-by-list \t subject + # Co-authored-by trailers are joined with 0x1f (unit separator) which + # cannot appear in identity strings. Tabs aren't valid in identity + # fields either, so awk -F'\t' parses unambiguously. bad=$(git rev-list \ - --format='%H%x09%G?%x09%cn%x09%ce%x09%an%x09%ae%x09%s' \ + --format='%H%x09%G?%x09%cn%x09%ce%x09%an%x09%ae%x09%(trailers:key=Co-authored-by,valueonly,unfold,separator=%x1f)%x09%s' \ --no-commit-header "$@" | awk -F'\t' \ -v ok="$ok" \ @@ -86,7 +87,15 @@ while read -r _local_ref local_sha remote_ref remote_sha; do if (is_agent(tolower($5 " " $6))) { reasons = reasons " [agent-author=" $5 " <" $6 ">]" } - if (reasons != "") print $1 reasons " " $7 + if ($7 != "") { + n_co = split($7, coauthors, "\037") + for (i = 1; i <= n_co; i++) { + if (coauthors[i] != "" && is_agent(tolower(coauthors[i]))) { + reasons = reasons " [agent-coauthor=" coauthors[i] "]" + } + } + } + if (reasons != "") print $1 reasons " " $8 } ') -- cgit v1.3.1