The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 09:45 UTC
fix(source-control-bitbucket): read ssh.bitbucket.org remotes as Bitbucket Cloud (#37892)
Julius Marminge committed
Nov 16, 2026 at 20:35 UTC
f0572cf1b96b979c7c98e6d5f855cc7c9f475697
4 files changed
+34
-9
packages/shared/src/cloneUrl.test.ts
+9
@@ -78,6 +78,15 @@ describe("cloneUrlForProtocol", () => {
78
);
79
});
80
81
+ it("switches Bitbucket Cloud between its SSH and HTTPS hosts", () => {
82
+ expect(cloneUrlForProtocol("https://bitbucket.org/workspace/repo.git", "ssh")).toBe(
83
+ "git@ssh.bitbucket.org:workspace/repo.git",
84
+ );
85
+ expect(cloneUrlForProtocol("git@ssh.bitbucket.org:workspace/repo.git", "https")).toBe(
86
+ "https://bitbucket.org/workspace/repo.git",
87
+ );
88
+ });
89
+
90
it("preserves encoded Azure repository components and same-protocol URLs", () => {
91
const ssh = "git@ssh.dev.azure.com:v3/Fabrikam/Project%20One/fab%20repo";
92
const https = "https://dev.azure.com/Fabrikam/Project%20One/_git/fab%20repo";
packages/shared/src/cloneUrl.ts
+8
-2
@@ -56,13 +56,19 @@ export function cloneUrlForProtocol(url: string, protocol: CloneProtocol): strin
56
const azure = /^([^/?#]+)\/([^/?#]+)\/_git\/([^/?#]+)$/.exec(parsed.path);
57
return azure ? `git@ssh.dev.azure.com:v3/${azure[1]}/${azure[2]}/${azure[3]}` : null;
58
}
59
+ // Bitbucket Cloud serves SSH only from `ssh.bitbucket.org` and HTTPS only from `bitbucket.org`.
60
+ const host = /^(?:(?:alt)?ssh\.)?bitbucket\.org$/i.test(parsed.host)
61
+ ? protocol === "ssh"
62
+ ? "ssh.bitbucket.org"
63
+ : "bitbucket.org"
64
+ : parsed.host;
65
// SCP paths are literal; URI paths use percent escapes.
66
try {
61
- if (protocol === "ssh") return `git@${parsed.host}:${decodeURIComponent(parsed.path)}`;
67
+ if (protocol === "ssh") return `git@${host}:${decodeURIComponent(parsed.path)}`;
68
const path = parsed.scp
69
? parsed.path.split("/").map(encodeURIComponent).join("/")
70
: parsed.path;
65
- return `https://${parsed.host}/${path}`;
71
+ return `https://${host}/${path}`;
72
} catch {
73
return null;
74
}
packages/source-control-bitbucket/src/shared/definition.test.ts
+11
@@ -76,4 +76,15 @@ describe("Bitbucket remotes", () => {
76
);
77
expect(recognize("https://notbitbucket.example.com/workspace/repo.git")).toBeNull();
78
});
79
+
80
+ it.each([
81
+ "git@ssh.bitbucket.org:workspace/repo.git",
82
+ "ssh://git@altssh.bitbucket.org:443/workspace/repo.git",
83
+ ])("recognises Bitbucket Cloud's SSH host in %s", (url) => {
84
+ expect(recognize(url)).toEqual({
85
+ kind: "bitbucket",
86
+ name: "Bitbucket",
87
+ baseUrl: "https://bitbucket.org",
88
+ });
89
+ });
90
});
packages/source-control-bitbucket/src/shared/definition.ts
+6
-7
@@ -124,14 +124,13 @@ export const definition = defineSourceControl({
124
);
125
},
126
checkoutChangeRequestHost: () => null,
127
+ // Cloud also clones from `ssh.bitbucket.org` and `altssh.bitbucket.org`.
128
recognizeRemote: ({ host, hostname }) =>
128
- hostname === "bitbucket.org" || hostname.split(".").includes("bitbucket")
129
- ? {
130
- kind: KIND,
131
- name: hostname === "bitbucket.org" ? "Bitbucket" : "Bitbucket Self-Hosted",
132
- baseUrl: `https://${host}`,
133
- }
134
- : null,
129
+ hostname === "bitbucket.org" || hostname.endsWith(".bitbucket.org")
130
+ ? { kind: KIND, name: "Bitbucket", baseUrl: "https://bitbucket.org" }
131
+ : hostname.split(".").includes("bitbucket")
132
+ ? { kind: KIND, name: "Bitbucket Self-Hosted", baseUrl: `https://${host}` }
133
+ : null,
134
isChangeRequestInRepository: (identity, link) =>
135
isChangeRequestInProjectRepository(projectChangeRequestHost(identity, KIND), identity, link),
136
canReadChangeRequestOnHost: (identity, link) =>