fix(shared): resolve SSH config host aliases in git remote URLs - #9487
fix(shared): resolve SSH config host aliases in git remote URLs#9487ylcn91 wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This focused bug fix corrects SSH host-alias handling across repository identity, provider detection, and pull-request lookup while preserving HTTPS and self-hosted behavior. The implementation is small, isolated, and covered by targeted regression tests. You can add or adjust custom eligibility rules. Learn more. |
|
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing this alternative in favor of #7186, where review continues on actual SSH |
What Changed
packages/shared/src/sourceControl.ts:parseRemoteHoststrips an SSH config alias suffix from SSH hosts before provider detection, sogit@github.com-work:org/repo.gitnow yieldsbaseUrl: "https://github.com"instead ofhttps://github.com-work. The rule lives in a newstripSshHostAliashelper.packages/shared/src/git.ts:normalizeGitRemoteUrlcanonicalizes the same way, so the repository identity key (and every host the app derives from it: the pull request host, the browser link, the list de-duplication key) readsgithub.com/org/repo.parseGitHubRepositoryNameWithOwnerFromRemoteUrlaccepts the aliased host.apps/server/src/git/GitManager.ts: the same one-token regex change on its local copy of that parser, so PR lookups resolveowner/repofor aliased remotes.Focused tests for each: the alias forms, ports on
ssh://URLs, and the hosts that must stay as written (self-hosted and internal names, HTTPS remotes).Why
Fixes #9458.
A
Host github.com-workentry in~/.ssh/configis the standard way to drive several GitHub accounts from one machine, and the remote then readsgit@github.com-work:org/repo.git. T3 Code took that alias host literally: it became the identity's canonical key, the provider base URL, and the pull request URL, so reading a PR hithttps://github.com-work/org/repo/pull/123and failed on DNS.The rule is deliberately narrow. Only SSH transports consult the SSH config, so HTTPS hosts are never touched. Only the hosted provider domains this module already special-cases (
github.com,gitlab.com,bitbucket.org,ssh.dev.azure.com) followed by-are treated as an alias; a self-hosted or internal name such asgithub.example-corpis taken as written, since an internal zone may legitimately carry a hyphen there. Aliases that do not embed the real host at all (Host work) would needssh -Gresolution and are out of scope for this fix.Existing projects pick up the corrected identity the next time it is resolved; nothing is migrated.
Model and harness: Claude Fable 5.1 in Claude Code.
Note
Fix
parseGitHubRepositoryNameWithOwnerFromRemoteUrlto accept SSH config host aliasesExtends the GitHub SSH URL pattern in
parseGitHubRepositoryNameWithOwnerFromRemoteUrlto match hostnames likegithub.com-workfor both SCP-style andssh://remotes. This lets the parser extractowner/repofrom remotes that use SSH config host aliases (e.g.git@github.com-work:owner/repo.git). HTTPS andgit://patterns are unchanged.github.com-*alias; verify no such remotes are expected in practice.Macroscope summarized de7462b.