fix(shared): resolve multi-account SSH alias hosts to the real provider host - #9497
fix(shared): resolve multi-account SSH alias hosts to the real provider host#9497Mnigos wants to merge 1 commit into
Conversation
…er host A remote like git@github.com-work:org/repo.git, the documented ~/.ssh/config convention for multiple accounts, leaked the alias into every derived value: the provider base URL became https://github.com-work, the normalized identity key kept the alias so PR URLs never matched the project, and the owner/repo parser returned null. SSH remotes now canonicalize an aliased github.com, gitlab.com, or bitbucket.org host back to the real one; HTTPS remotes keep their literal host. Also drops GitManager's private copy of the owner/repo parser in favor of the shared one. Fixes pingdotgg#9458
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused SSH remote-parsing bug fix with tests, changing only derived provider and repository identity data for recognized aliases while preserving existing HTTPS and unrelated-host behavior. No schema, authentication, deployment, product-default, or static-analysis configuration changes are involved. 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, which resolves |
A remote like
git@github.com-work:org/repo.git, the documented~/.ssh/configconvention for multiple GitHub accounts on one machine, leaks the alias into everything derived from the remote: the provider base URL becomeshttps://github.com-work(the invalid domain from the issue), the normalized identity key keeps the alias so PR URLs never match the project, and the GitHubowner/repoparser returns null.SSH remotes now canonicalize an aliased
github.com,gitlab.com, orbitbucket.orghost back to the real one before deriving the base URL, the identity key, andowner/repo. HTTPS remotes keep their literal host, since only SSH goes through~/.ssh/configaliasing. GitManager's private copy of the owner/repo parser was byte-identical to the shared one, so it now imports it instead.Covered by tests for all three derivations; each fails without the fix.
Fixes #9458.
Implemented with Claude Code (Claude Fable 5).
Note
Low Risk
Narrow URL-parsing fix with tests; affects remote identity and PR association for SSH aliases but does not change auth or git execution.
Overview
Fixes broken provider detection, normalized remote identity keys, and GitHub
owner/repoparsing when remotes use common~/.ssh/configSSH host aliases (e.g.git@github.com-work:org/repo.git).Shared layer: Adds
canonicalizeSshRemoteHostnameforgithub.com,gitlab.com, andbitbucket.orgalias suffixes, applied only for SSH remotes in provider detection and innormalizeGitRemoteUrl(URL and SCP forms). Extends the GitHub owner/repo parser regex for aliased SSH hosts. HTTPS remotes still use the literal hostname (e.g. self-hostedgithub.com-work).Server:
GitManagerdrops its duplicate GitHub parser and importsparseGitHubRepositoryNameWithOwnerFromRemoteUrlfrom shared so behavior stays in sync.New unit tests cover alias canonicalization, non-SSH hosts left unchanged, and parsing through aliases.
Reviewed by Cursor Bugbot for commit 1f21017. Configure here.
Note
Resolve multi-account SSH alias hosts to canonical provider host in shared git utils
canonicalizeSshRemoteHostnamein sourceControl.ts to map recognized SSH aliases for GitHub, GitLab, and Bitbucket to their canonical public hostnames; other hostnames pass through unchanged.detectSourceControlProviderFromRemoteUrlandnormalizeGitRemoteUrlin git.ts to canonicalize the hostname only for SSH remotes, so HTTPS hosts that resemble aliases stay literal.parseGitHubRepositoryNameWithOwnerFromRemoteUrlto accept SSH host alias suffixes for both SCP-style and SSH-URL remotes; HTTPS and git-protocol forms still require the canonical GitHub host.canonicalizeSshRemoteHostnameonly recognizes a fixed set of alias hosts; SSH remotes using custom or future alias schemes will not be canonicalized and may be misclassified as self-hosted.Macroscope summarized 1f21017.