diff --git a/.githooks/commit-msg b/.githooks/commit-msg index c8d3100..d869c66 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -1,6 +1,9 @@ #!/bin/sh -# Reject any AI attribution in commit messages. -if grep -qiE 'claude|anthropic|co-authored-by|generated with|ai-assisted' "$1"; then +# Reject AI attribution in commit messages (Claude/Anthropic/"generated with"/ +# "ai-assisted"). Plain Co-authored-by trailers are allowed: GitHub adds them on +# squash-merge and for Dependabot, and an AI co-author is still caught by the +# name patterns above. +if grep -qiE 'claude|anthropic|generated with|ai-assisted' "$1"; then echo "commit-msg hook: forbidden attribution pattern found. Rewrite the message." >&2 exit 1 fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c343d70..6357201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,11 +64,13 @@ jobs: with: fetch-depth: 0 # CI mirror of .githooks/commit-msg: scan every commit message in - # the repository for forbidden attribution patterns. + # the repository for AI attribution. Plain Co-authored-by trailers are + # allowed (GitHub adds them on squash-merge and for Dependabot); an AI + # co-author is still caught by the name patterns. - name: audit commit messages run: | set -eu - pattern='claude|anthropic|co-authored-by|generated with|ai-assisted' + pattern='claude|anthropic|generated with|ai-assisted' matches=$(git log --format='%H %s %b' | grep -icE "$pattern" || true) if [ "$matches" -ne 0 ]; then echo "commit-audit: forbidden attribution pattern found in commit messages:" >&2