From 13e18af77720d8ed24bd83f659348e91e94bd323 Mon Sep 17 00:00:00 2001 From: akshathayadav378-boop Date: Sat, 14 Nov 2026 22:54:44 +0800 Subject: [PATCH] fix(vcs): open Bitbucket SSH clones on bitbucket.org (#3379) For a Bitbucket Cloud repository cloned over SSH (git@ssh.bitbucket.org:team/repo.git), Open In used ssh.bitbucket.org as the web host and GitLab routes. remoteWebUrl now maps the services' SSH front hosts (ssh.bitbucket.org, ssh.github.com, altssh.gitlab.com) to their web hosts before building the URL. Co-authored-by: akshathayadav378-boop <287247196+akshathayadav378-boop@users.noreply.github.com> --- src/features/vcs/__tests__/fileWebUrl.test.ts | 8 ++++++++ src/features/vcs/model.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/features/vcs/__tests__/fileWebUrl.test.ts b/src/features/vcs/__tests__/fileWebUrl.test.ts index 6b3e0138c..a6ea504f3 100644 --- a/src/features/vcs/__tests__/fileWebUrl.test.ts +++ b/src/features/vcs/__tests__/fileWebUrl.test.ts @@ -7,6 +7,8 @@ describe("remoteHosting", () => { ["https://github.example.com/o/r", "GitHub", "github"], ["https://gitee.com/o/r.git", "Gitee", "github"], ["git@bitbucket.org:o/r.git", "Bitbucket", "bitbucket"], + ["git@ssh.bitbucket.org:team/repo.git", "Bitbucket", "bitbucket"], + ["git@ssh.github.com:o/r.git", "GitHub", "github"], ["ssh://git@gitlab.example.com:2222/group/sub/r.git", "GitLab", "gitlab"], ["git@git.example.com:group/r.git", "git.example.com", "gitlab"], ])("%s → %s", (url, name, kind) => { @@ -43,4 +45,10 @@ describe("fileWebUrl", () => { "https://bitbucket.org/o/r/src/main/a.py#lines-5", ); }); + + it("opens a Bitbucket Cloud SSH clone on bitbucket.org, not the SSH front host (#3372)", () => { + expect(fileWebUrl("git@ssh.bitbucket.org:team/repo.git", "main", "a.py", { line: 4 })).toBe( + "https://bitbucket.org/team/repo/src/main/a.py#lines-5", + ); + }); }); diff --git a/src/features/vcs/model.ts b/src/features/vcs/model.ts index 9e82e02e4..ce3d69052 100644 --- a/src/features/vcs/model.ts +++ b/src/features/vcs/model.ts @@ -139,6 +139,13 @@ export function stashLabel(message: string): { branch: string | null; text: stri return { branch: m[1]!, text: m[2]!.trim() || message }; } +/** SSH front hosts that serve the same service as the web host in the value. */ +const WEB_HOST_ALIASES: Record = { + "ssh.bitbucket.org": "bitbucket.org", + "ssh.github.com": "github.com", + "altssh.gitlab.com": "gitlab.com", +}; + /** * Web page of a git remote URL (`git@github.com:o/r.git`, `ssh://git@host:22/o/r`, * `https://user@host/o/r.git`), or null for local paths. @@ -155,6 +162,7 @@ export function remoteWebUrl(url: string): string | null { if (full) [, host, path] = full as unknown as [string, string, string]; else if (scp) [, host, path] = scp as unknown as [string, string, string]; else return null; + host = WEB_HOST_ALIASES[host.toLowerCase()] ?? host; return `https://${host}/${path.replace(/^\/+/, "")}`; }