Skip to content

Resolve PR repo via gh repo view so fork clones target upstream#261

Merged
sbertix merged 2 commits intomainfrom
sbertix/255-remote-name
Apr 20, 2026
Merged

Resolve PR repo via gh repo view so fork clones target upstream#261
sbertix merged 2 commits intomainfrom
sbertix/255-remote-name

Conversation

@sbertix
Copy link
Copy Markdown
Collaborator

@sbertix sbertix commented Apr 20, 2026

Summary

  • GithubCLIClient.resolveRemoteInfo shells gh repo view --json owner,name,url in repoRoot and reuses gh's own default-repo resolution. The reducer prefers it over gitClient.remoteInfo, so fork clones pushing to upstream now query the upstream repo. mergePullRequest / closePullRequest / markPullRequestReady take the resolved GithubRemoteInfo and pass --repo HOST/OWNER/REPO so mutations hit the same repository the refresh pipeline queried.
  • Tiered 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.
  • CI/workflow calls (gh run list, rerun failed jobs, view run logs) still target repoRoot — workflow runs live on whichever remote received the push, which in fork workflows is the fork.

Test plan

  • make test — new tests cover gh repo view parsing, fallback to git remote (refresh + merge paths), --repo forwarding for all three mutations, tier-2-over-tier-3 precedence, and the deleted-fork regression from PR Add RubyMine editor option #248.
  • make build-app
  • make check
  • Manual: in a fork clone with the PR opened against upstream, confirm the worktree row shows the PR badge + CI ring and that Merge / Close / Mark ready act on the upstream PR.
  • Manual: check out a merged PR whose fork has been deleted (e.g. gh pr checkout 248) and confirm the worktree surfaces it as MERGED.

Closes #255

sbertix added 2 commits April 20, 2026 23:06
`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`).
@sbertix sbertix enabled auto-merge (squash) April 20, 2026 21:09
@sbertix sbertix merged commit a4cdad9 into main Apr 20, 2026
2 checks passed
@sbertix sbertix deleted the sbertix/255-remote-name branch April 20, 2026 21:14
@tuist
Copy link
Copy Markdown

tuist Bot commented Apr 20, 2026

🛠️ Tuist Run Report 🛠️

Builds 🔨

Scheme Status Duration Commit
supacode 1m 9s 5bab09189

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.

PR status does not show up for PRs opened from a fork to the upstream repo

1 participant