fix: review PR head in reused workspace (stale pr-review branch)#40
Merged
Conversation
pr-af reuses a persistent /workspaces clone across reviews. _checkout_pr_branch
fetched the PR head directly into the local `pr-review` branch:
git fetch --depth 1 origin pull/<N>/head:pr-review
git checkout pr-review
When the workspace is reused, the previous review leaves `pr-review` checked
out, and git *refuses* to fetch into the currently checked-out branch
("refusing to fetch into branch '...' checked out at ..."). The failure was
swallowed (capture_output, no return-code check), so every PR after the first
in a container's lifetime was reviewed against the first PR's working tree.
The anatomy phase then saw the diff not matching the tree and returned zero
findings — github-buddy silently "passed" PRs without reviewing them.
Fix: fetch the PR head to FETCH_HEAD (always allowed) and point the branch at
it with `git checkout -B pr-review FETCH_HEAD`, which works even when pr-review
is the current branch. Both git calls now check their return code and raise,
so a failed fetch/checkout surfaces instead of silently reviewing a stale tree.
Adds tests/test_resolve_repo.py with real-git behavior tests covering fresh
workspace, reused workspace (the regression), and unfetchable-ref failure.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
pr-af reuses a persistent
/workspaces/<repo>clone across reviews._checkout_pr_branchfetched the PR head directly into the localpr-reviewbranch:When the workspace is reused, the previous review leaves
pr-reviewchecked out, and git refuses to fetch into the currently checked-out branch (refusing to fetch into branch '...' checked out at ...). That failure was swallowed (capture_output=True, no return-code check), so:On Railway,
/workspacesis ephemeral (no volume attached), so the stale branch only resets on redeploy — meaning in steady state most PRs were getting rubber-stamped.Fix
FETCH_HEAD(always allowed, even withpr-reviewchecked out), then point the branch at it withgit checkout -B pr-review FETCH_HEAD.Tests
New
tests/test_resolve_repo.py— real-git behavior tests (no mocking of internals):Validation
ruff check src/ scripts/— passes (CI lint gate)test_create_request_fails_fast_when_hax_wedges), which fails identically onmain.🤖 Generated with Claude Code