Skip to content
Merged
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
16 changes: 16 additions & 0 deletions packages/shared/src/sourceControl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ describe("detectSourceControlProviderFromRemoteUrl", () => {
).toBe("bitbucket");
});

it("detects GitHub Enterprise Cloud data residency hosts on ghe.com", () => {
expect(detectSourceControlProviderFromRemoteUrl("https://acme.ghe.com/owner/repo.git")).toEqual(
{
kind: "github",
name: "GitHub Self-Hosted",
baseUrl: "https://acme.ghe.com",
},
);
expect(detectSourceControlProviderFromRemoteUrl("git@acme.ghe.com:owner/repo.git")?.kind).toBe(
"github",
);
expect(detectSourceControlProviderFromRemoteUrl("https://ghe.com/owner/repo.git")?.kind).toBe(
"unknown",
);
});

it("does not match provider names embedded in unrelated DNS labels", () => {
expect(
detectSourceControlProviderFromRemoteUrl("https://notgithub.example.com/owner/repo.git")
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/sourceControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ function hasDnsLabel(host: string, label: string): boolean {
return host.split(".").includes(label);
}

/** `*.ghe.com` is GitHub Enterprise Cloud with data residency, one subdomain per enterprise. */
function isGitHubHost(host: string): boolean {
return host === "github.com" || hasDnsLabel(host, "github");
return host === "github.com" || host.endsWith(".ghe.com") || hasDnsLabel(host, "github");
}

function isGitLabHost(host: string): boolean {
Expand Down
Loading