Repository navigation
fix(review): let offload-review review a PR from a fork - #979
Merged
Merged
Conversation
The script fetched the PR's headRefName from origin. A fork PR branch is not on origin, so the fetch failed with "couldn't find remote ref" and the script exited 128 before any reviewer started. Fetch refs/pull/<n>/head instead. It exists for same-repo and fork PRs. Then check that the head sha from gh is present, and fail with a clear message if the PR ref lags behind. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
commented
Nov 9, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | aa7401ba3a5d |
approve |
Verdict: approve
Findings
None.
Non-blocking
scripts/offload-review.sh:130—--jsonstill asks forheadRefName, but nothing uses it now. Drop it, or keep it; it costs one field.scripts/offload-review.sh:173—2>/dev/nulloncat-filehides every error behind the "not in refs/pull yet" message. A broken object store would print the same advice. Minor: the message could say "checkgit cat-fileby hand" on failure.- The script has no test harness in the repo, so the fork-PR fetch path has no test. Earlier fixes to this script (#697, #699) shipped the same way. If a harness ever appears, the two cases worth a test are: a fork PR head, and a
refs/pull/N/headthat lags thegh-reported sha.
What I checked
- Read the full diff (one file,
scripts/offload-review.sh, +8/−2) and the whole script around it. - The bug is real: a fork PR's head branch is absent from
origin, so the oldgit fetch origin "$head_ref"(line 171 before the change) failed before any reviewer ran.refs/pull/N/headexists on the base repo for every PR, fork or not, so the new refspec fixes both cases. - The lag guard is sound.
gh pr viewandgit fetchcan see different heads when a push lands in between. The guard at lines 173–176 runs before any worktree or session is touched, and every later step pins the exact$sha:worktree add --detach "$sha"(line 196),checkout --detach "$sha"(line 194), and the HEAD check (line 428). So the script cannot review a commit other than the oneghreported. A force-push in that window makes the guard exit 1 with a clear message; nothing is half-run. - The base fetch is unchanged. Fetching a plain branch name updates
origin/$base_ref(git does this opportunistically since 1.8.4), so the merge base at line 307 stays correct. I grepped the repo: nothing else readsorigin/<head ref>, so dropping the head-branch fetch breaks nothing. - The removed
head_refvariable has no other user. refs/pull/N/headpoints at the last head even when the head branch is deleted, so the new code handles that case too; the old code failed there.- Checked the repo rules that could apply: fail-open and data-dependence apply to the proxy and library, not to this dev script. The change alters repo tooling only, not user-facing behavior, so the "human permission for behavior change" rule does not apply.
- Read
CLAUDE.mdanddocs/design.mdas the process requires. No Go tests were run; live tests are not approved.
amiddavid
commented
Nov 9, 2026
amiddavid
left a comment
Collaborator
Author
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | aa7401ba3a5d |
approve |
Verdict: approve
Findings
None.
Non-blocking
scripts/offload-review.sh:130—--jsonstill asks forheadRefName, but nothing reads it now. Drop it, or keep it as a comment on what the PR is. No effect on behavior.scripts/offload-review.sh:43-46— the header's exit-code list does not cover the new exit 1 ("head is not in refs/pull/N/head yet").SKILL.md's exit table says exit 1 means "stop and report". The message itself says "Run again in a minute", so the operator gets the right action. A one-line note in the header would make the docs match.- No test covers the script. The repo has no shell test harness, and the PR says the fetch was checked by hand on PRs #483 and #976. Acceptable for this size.
What I checked
- Read the full diff (one commit,
scripts/offload-review.shonly) and the whole script around it. - The fix is correct.
refs/pull/N/headexists on the base repo for every PR, fork or not. The old fetch ofheadRefNamefailed for a fork PR, because that branch lives on the fork, not onorigin. The new fetch cannot fail that way. origin/$base_refstill updates.git fetch origin <branch>also updates the tracking ref (git since 1.8.4).attemptusesgit merge-base "origin/$base_ref" HEADat line 307. The base branch is always onorigin, fork or not. This behavior is unchanged by the diff.- The lag guard covers the right race.
gh pr viewreads the head at one moment; the fetch readsrefs/pull/N/headat a later one.- PR ref older than the reported sha:
cat-file -efails, the script exits 1 before any reviewer or worktree runs. No wasted run, no wrong review. - PR ref newer (a push came in between): the reported sha is an ancestor, so it is present. The review runs on the sha that
ghreported, and the marker names that sha. The review and the marker agree. - The sha present locally for another reason (an earlier round, a local branch): the guard passes, and the review still runs on the sha
ghreported. Correct target either way.
- PR ref older than the reported sha:
- Nothing else assumed a same-repo head branch. I grepped the script, the three backends, and
SKILL.md. Only$sha,$base_refand the worktree path are used downstream. The removedhead_refvariable had no other reader. - Fail-open rules do not apply. The script is dev tooling, not the proxy or the library. No component, config or data dependence changes.
components/all/datadep_test.gois untouched. bash -npasses.shellcheckis not installed, same as in the PR.- Confirmed the commit topology:
aa7401bahas parent569c609b(the base). One commit, fast-forward.
Exit 1 also covers a PR head that is not in refs/pull/N/head yet. Comment lines only. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Collaborator
Author
|
The comment note is fixed in 8e3a3fa. The header now lists the new exit 1 case.
|
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
offload-reviewnow works for a PR from a fork.What we found
AIMikav:feat/opencode-plugin. That branch is not onorigin.git fetch origin <headRefName> <base>.fatal: couldn't find remote ref feat/opencode-plugin.What changed
refs/pull/$pr/headand the base branch. This ref exists for every PR.origin/$base_refstays current, as before.ghexists locally. If not, it stops with a clear message. This covers a push that came in between.head_refvariable is gone.Behavior change
How it was tested
bash -n scripts/offload-review.shpasses.shellcheckis not installed.33e0eb8b: found.d407a703: found.feat/opencode-plugin: fails withcouldn't find remote ref.🤖 Generated with Claude Code