Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/client-runtime/src/sourceControlClients.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ describe("sourceControlClients repository keys", () => {
["git@ssh.dev.azure.com:v3/o/p", "ssh.dev.azure.com/v3/o/p"],
["ssh.dev.azure.com/v3/o/p/r", "ssh.dev.azure.com/v3/o/p/r"],
["C:/repos/project", "c:/repos/project"],
["git@altssh.bitbucket.org:Owner/Repo.git", "bitbucket.org/owner/repo"],
["ssh://git@ssh.github.com:443/Owner/Repo.git", "github.com/owner/repo"],
["git@altssh.gitlab.com:Group/Sub/Repo.git", "gitlab.com/group/sub/repo"],
["git@ssh.example.com:Owner/Repo.git", "ssh.example.com/owner/repo"],
])("keys %s as %s", (remote, key) => {
expect(sourceControlClients.repositoryKeyFromRemote(remote)).toBe(key);
});
Expand Down
5 changes: 5 additions & 0 deletions packages/source-control-bitbucket/src/shared/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export const definition = defineSourceControl({
baseUrl: `https://${host}`,
}
: null,
// `altssh.bitbucket.org` is the SSH-only host for networks that block port 22; it serves the web host's repositories.
repositoryKeyFromRemote: (key) => {
const match = /^altssh\.bitbucket\.org\/(.+)$/u.exec(key);
return match === null ? null : `bitbucket.org/${match[1]}`;
},
isChangeRequestInRepository: (identity, link) =>
isChangeRequestInProjectRepository(projectChangeRequestHost(identity, KIND), identity, link),
canReadChangeRequestOnHost: (identity, link) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ describe("selectGitHubBaseRepository", () => {
owner: "me",
name: "web",
});
const sshFork = fork.replace(
"git@github.com:me/web.git",
"ssh://git@ssh.github.com:443/me/web.git",
);
assert.deepStrictEqual(
select({ remotes: sshFork, resolved: "remote.origin.gh-resolved base" }),
{
owner: "me",
name: "web",
},
);
assert.deepStrictEqual(
resolveGitHubRepository({
remotes: sshFork,
resolved: "remote.origin.gh-resolved base",
hostHint: "ssh.github.com",
defaultHost: "github.com",
}),
{ host: "github.com", locator: { host: "github.com", owner: "me", name: "web" } },
);
assert.deepStrictEqual(
select({ remotes: fork, resolved: "remote.origin.gh-resolved acme/other" }),
{ owner: "acme", name: "other" },
Expand Down Expand Up @@ -162,6 +182,7 @@ describe("parseGitHubRepositorySelector", () => {
describe("gitHubApiHostForRemote", () => {
it("reads an SSH alias through github.com and a real host as itself", () => {
assert.strictEqual(gitHubApiHostForRemote("git@github:acme/web.git"), "github.com");
assert.strictEqual(gitHubApiHostForRemote("git@ssh.github.com:acme/web.git"), "github.com");
assert.strictEqual(
gitHubApiHostForRemote("git@github.example.com:a/b.git"),
"github.example.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export function parsePullRequestReference(
const GITHUB_DOT_COM_SSH_ALIAS = /^github\.com-[a-z0-9_-]+$/u;

function apiHostForSshAlias(host: string): string | null | undefined {
if (host === "ssh.github.com") return "github.com";
if (!host.includes(".")) return host.includes("github") ? "github.com" : null;
return GITHUB_DOT_COM_SSH_ALIAS.test(host) ? "github.com" : undefined;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/source-control-github/src/shared/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export const definition = defineSourceControl({
baseUrl: `https://${host}`,
}
: null,
// `ssh.github.com` is the SSH-only host for networks that block port 22; it serves the web host's repositories.
repositoryKeyFromRemote: (key) => {
const match = /^ssh\.github\.com\/(.+)$/u.exec(key);
return match === null ? null : `github.com/${match[1]}`;
},
isChangeRequestInRepository: (identity, link) =>
isChangeRequestInProjectRepository(projectChangeRequestHost(identity, KIND), identity, link),
canReadChangeRequestOnHost: (identity, link) =>
Expand Down
5 changes: 5 additions & 0 deletions packages/source-control-gitlab/src/shared/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const definition = defineSourceControl({
baseUrl: `https://${host}`,
}
: null,
// `altssh.gitlab.com` is the SSH-only host for networks that block port 22; it serves the web host's repositories.
repositoryKeyFromRemote: (key) => {
const match = /^altssh\.gitlab\.com\/(.+)$/u.exec(key);
return match === null ? null : `gitlab.com/${match[1]}`;
},
isChangeRequestInRepository: (identity, link) =>
isChangeRequestInProjectRepository(projectChangeRequestHost(identity, KIND), identity, link),
canReadChangeRequestOnHost: (identity, link) =>
Expand Down
Loading