Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.

fix(server): repository identity prefers the gh default remote - #42

Merged
donnes merged 3 commits into
mainfrom
t3code/prefer-gh-resolved-remote
Sep 29, 2026
Merged

donnes merged 3 commits into
mainfrom
t3code/prefer-gh-resolved-remote

Conversation

@donnes

@donnes donnes commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What Changed

RepositoryIdentityResolver now checks for a remote marked by gh repo set-default and prefers it. gh stores remote.<name>.gh-resolved as base for that remote's own repo, or as OWNER/REPO when the chosen parent repo has no remote. The second case resolves to that repo on the marked remote's host, the same way gh does. Only after that does it fall back to the existing order: upstream, then origin, then the first remote alphabetically. Resolving an identity reads that config with one git config --get-regexp call, which runs in parallel with git remote -v. It only runs on a cache miss.

Why

In a fork with both origin (the fork) and upstream remotes, the project's repository identity always resolved to upstream. That identity also drives PR detection, lookup and linking, so a fork's PRs were looked up against the upstream repo and "View PR" opened the wrong one. gh users already record which repo PRs belong to with gh repo set-default, so honoring it fixes forks without adding a setting. Repos where no default is set behave exactly as before.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (none)
  • I included a video for animation/interaction changes (none)

Model: Claude Opus 5.5 (1M context), running in Claude Code inside T3 Code.

🤖 Generated with Claude Code

A fork with both `origin` and `upstream` resolved its repository identity to
`upstream`, so PR lookups and "View PR" pointed at the upstream repo. When
`gh repo set-default` has marked a remote (`remote.<name>.gh-resolved base`),
use that remote before falling back to upstream, origin, then alphabetical.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 29, 2026
donnes and others added 2 commits September 29, 2026 15:05
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`gh repo set-default` stores OWNER/REPO instead of `base` when the chosen
parent repository has no remote. Resolve it on the marked remote's host.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@donnes
donnes merged commit 685b4b8 into main Sep 29, 2026
15 checks passed
@donnes
donnes deleted the t3code/prefer-gh-resolved-remote branch September 29, 2026 18:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant