fix(git-guards): enforce kernel coding-assistants trailer spec#333
Merged
Conversation
…nd robot signature - Expand TRAILER_PATTERN to match bare `Assisted-by: Claude` (no model) in addition to the existing email form `Assisted-by: Claude <...>`; already-correct `Assisted-by: Claude:<model>` is explicitly excluded - Add robot-signature stripping: removes `🤖 Generated with [Claude Code]` lines (and the preceding blank line) from any Bash command — commits, PR body heredocs, etc. Blank-line variant replaced with \n to keep heredoc EOF delimiters on their own lines - Restructure main() so robot strip and trailer fix are independent paths; robot strip is transcript-independent (never fails open) - Update reason string to report which transforms were applied - Add 5 new tests: bare trailer rewrite, robot line in commit, robot line in gh pr create, both combined, robot strip without transcript Refs: https://docs.kernel.org/process/coding-assistants.html Assisted-by: Claude:claude-opus-4-7
There was a problem hiding this comment.
Code Review
This pull request updates the commit-trailer-guard.py script to enforce the kernel coding-assistants specification by rewriting bare or email-formatted Assisted-by: Claude trailers and stripping robot-signature lines. It also introduces comprehensive test cases for these scenarios. The review feedback highlights two important improvements: adding a word boundary (\b) to the TRAILER_PATTERN regular expression to prevent false-positive matches on names starting with "Claude" (such as "Claudette"), and adding corresponding test cases that utilize explicit assert statements to ensure CI failures on regressions.
…-prefixed names Without \b after "Claude", the TRAILER_PATTERN incorrectly matched names like "Assisted-by: Claudette <...>" via the negative-lookahead path. Add \b so only the standalone word "Claude" matches. Also add test 13: verifies "Claudette" is NOT rewritten (silent allow). Assisted-by: Claude:claude-opus-4-7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enforce the kernel.org coding-assistants trailer spec:
Assisted-by: Claude:<model>(e.g.Assisted-by: Claude:claude-opus-4-7). Rewrite incorrect forms (Assisted-by: Claude <email>, bareAssisted-by: Claude) and strip errant robot emoji lines from commits and PR description heredocs.Changes
\b) to prevent false matches on names like "Claudette"; expanded pattern to capture bareAssisted-by: Claudeand email form, rewriting both to spec-compliant format.🤖 Generated with [Claude Code]lines from commit messages andgh pr createbody heredocs, independent of transcript validation (never fails open).Test Plan
pytest git-guards/scripts/test_commit_trailer_guard.py— all 13 tests pass.Assisted-by: Claude <noreply@anthropic.com>are rewritten toAssisted-by: Claude:<model>; bareAssisted-by: Claudetrailers are rewritten; robot emoji lines are stripped from all sources.