aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/git/hooks
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:34 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:34 +0100
commit7bcd28569189858a493227696e5479c577d72368 (patch)
tree6ac49106674bee3897e636303c03123c3f5e5660 /dot_config/git/hooks
parent1e478ca7378260250b2d6a4474b1c0cc3d87451b (diff)
downloaddotfiles-7bcd28569189858a493227696e5479c577d72368.tar.gz
dotfiles-7bcd28569189858a493227696e5479c577d72368.tar.bz2
dotfiles-7bcd28569189858a493227696e5479c577d72368.zip
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.
Diffstat (limited to 'dot_config/git/hooks')
-rwxr-xr-xdot_config/git/hooks/executable_pre-push19
1 files changed, 14 insertions, 5 deletions
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
}
')