Resolve PR repo via gh repo view so fork clones target upstream#261
Merged
Resolve PR repo via gh repo view so fork clones target upstream#261
gh repo view so fork clones target upstream#261Conversation
`GitClient.remoteInfo` preferred the `origin` remote, so in fork workflows Supacode queried the fork instead of the upstream repo that actually hosts the PR. The worktree badge/CI ring never lit up and `Merge PR` / `Close PR` / `Mark ready for review` from the command palette ran `gh pr …` against the fork, where the PR does not exist. - `GithubCLIClient.resolveRemoteInfo` shells `gh repo view --json owner,name,url` in `repoRoot` and reuses `gh`'s own default-repo resolution. The reducer prefers this result and only falls back to `gitClient.remoteInfo` when `gh` is unavailable. - `mergePullRequest` / `closePullRequest` / `markPullRequestReady` now take the resolved `GithubRemoteInfo` and pass `--repo HOST/OWNER/REPO`, so mutations run against the repository the refresh pipeline just queried. - CI/workflow calls (`gh run list`, rerun failed jobs, view run logs) still target `repoRoot` — workflow runs live on the remote that received the push, which in fork workflows is the fork.
`pullRequestsByBranch` excluded every node with `headRepository: null`, which GitHub returns when the PR's source fork has been deleted — a routine outcome after a fork PR is merged and the author removes their fork. The local branch still matches the PR's `headRefName`, so Supacode should surface it. Tier the candidates instead of the previous two-bucket split: 1. upstream PRs (head repo == queried repo), 2. fork PRs with an intact `headRepository` and `baseRefName != branch` (guards against "user:main → main"), 3. deleted-fork PRs (`headRepository == nil`, same `baseRefName` guard) — only consulted when tiers 1 and 2 are empty so we never prefer a stub over a PR with verifiable provenance. The existing `skipsNilHeadRepositoryInForkFallback` still passes because the intact-fork node lands in tier 2 and wins. New `includesMergedPRWithDeletedForkHead` covers the regression this uncovered (observed on PR #248 in `supabitapp/supacode`).
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
GithubCLIClient.resolveRemoteInfoshellsgh repo view --json owner,name,urlinrepoRootand reusesgh's own default-repo resolution. The reducer prefers it overgitClient.remoteInfo, so fork clones pushing to upstream now query the upstream repo.mergePullRequest/closePullRequest/markPullRequestReadytake the resolvedGithubRemoteInfoand pass--repo HOST/OWNER/REPOso mutations hit the same repository the refresh pipeline queried.pullRequestsByBranch(upstream → intact-fork → deleted-fork) so merged PRs whose source fork has been deleted (headRepository: null) still surface on the local branch. Tier 3 only runs when tiers 1 and 2 are empty, so a deleted-fork entry never outranks one with verifiable provenance.gh run list, rerun failed jobs, view run logs) still targetrepoRoot— workflow runs live on whichever remote received the push, which in fork workflows is the fork.Test plan
make test— new tests covergh repo viewparsing, fallback to git remote (refresh + merge paths),--repoforwarding for all three mutations, tier-2-over-tier-3 precedence, and the deleted-fork regression from PR Add RubyMine editor option #248.make build-appmake checkgh pr checkout 248) and confirm the worktree surfaces it as MERGED.Closes #255