Skip to content

fix(detect): keep A14 push match inside the git push invocation - #45

Merged
CybotTM merged 1 commit into
mainfrom
fix/retro-a14-branch-context
Jul 25, 2026
Merged

fix(detect): keep A14 push match inside the git push invocation#45
CybotTM merged 1 commit into
mainfrom
fix/retro-a14-branch-context

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 25, 2026

Copy link
Copy Markdown
Member

Problem

GIT_PUSH_TO_MAIN matched \bgit\s+push\b[^\n]*\b(?:HEAD:)?(?:main|master). The [^\n]* spans the entire line, including past |, && and ; into whatever command follows.

So an ordinary feature-branch push chained with a read-only command that happens to mention main:

git push 2>&1 | tail -2 && git log --oneline origin/main..HEAD

was reported as A14 "worked on main/master". The main that matched belongs to git 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 the git push invocation.

Two tests:

  • feature-branch push chained with git log origin/main..HEAD → does not fire
  • git 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 on feat/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
  • re-ran the detector against the real transcript, output above

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>
Copilot AI review requested due to automatic review settings July 25, 2026 16:08
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM merged commit 1bb8274 into main Jul 25, 2026
10 of 11 checks passed
@CybotTM
CybotTM deleted the fix/retro-a14-branch-context branch July 25, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants