fix(detect): keep A14 push match inside the git push invocation - #45
Merged
Conversation
GIT_PUSH_TO_MAIN used `[^\n]*` between `git push` and the branch name, so the match ran past shell separators into whatever followed on the same line. A feature-branch push chained with a read-only command that mentions main — `git push 2>&1 | tail -2 && git log --oneline origin/main..HEAD` — was flagged as work on main. The docstring already promised that a push only counts when it targets main; the separator guard makes that true. Bounding at `;&|` keeps a real violation firing when main is inside the push invocation itself. Found by running /retro against its own session: A14 reported one finding on a transcript with no main-branch work, and reports none after the fix. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
|
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.



Problem
GIT_PUSH_TO_MAINmatched\bgit\s+push\b[^\n]*\b(?:HEAD:)?(?:main|master). The[^\n]*spans the entire line, including past|,&∧into whatever command follows.So an ordinary feature-branch push chained with a read-only command that happens to mention main:
was reported as A14 "worked on main/master". The
mainthat matched belongs togit log's revision range, not to the push.The function's own docstring already states the intended behaviour — "a push only counts when it targets the main branch — pushing a tag or another ref while standing on main is legitimate and does not fire". The separator guard is what makes that true.
Change
[^\n]*→[^\n;&|]*, bounding the match to thegit pushinvocation.Two tests:
git log origin/main..HEAD→ does not firegit push origin main && echo done→ still fires (the guard must not swallow a real violation)How it was found
Running
/retro "fix the retro skill"against this session's own transcript. A14 reported one finding on a session whose git work happened entirely onfeat/retro-mechanical-first.Before:
--signals A14→ 1 finding.After:
--signals A14→ 0 findings on the same transcript.Verification
python3 -m pytest tests/ -q— 78 passed (was 76)pre-commit run --files <both>— ruff, ruff-format, markdownlint clean