Skip to content

Commit 93d0e1a

Browse files
authored
fix(shared): detect *.ghe.com remotes as GitHub (pingdotgg#19362)
1 parent 3755b49 commit 93d0e1a

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/shared/src/sourceControl.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ describe("detectSourceControlProviderFromRemoteUrl", () => {
147147
).toBe("bitbucket");
148148
});
149149

150+
it("detects GitHub Enterprise Cloud data residency hosts on ghe.com", () => {
151+
expect(detectSourceControlProviderFromRemoteUrl("https://acme.ghe.com/owner/repo.git")).toEqual(
152+
{
153+
kind: "github",
154+
name: "GitHub Self-Hosted",
155+
baseUrl: "https://acme.ghe.com",
156+
},
157+
);
158+
expect(detectSourceControlProviderFromRemoteUrl("[email protected]:owner/repo.git")?.kind).toBe(
159+
"github",
160+
);
161+
expect(detectSourceControlProviderFromRemoteUrl("https://ghe.com/owner/repo.git")?.kind).toBe(
162+
"unknown",
163+
);
164+
});
165+
150166
it("does not match provider names embedded in unrelated DNS labels", () => {
151167
expect(
152168
detectSourceControlProviderFromRemoteUrl("https://notgithub.example.com/owner/repo.git")

‎packages/shared/src/sourceControl.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ function hasDnsLabel(host: string, label: string): boolean {
179179
return host.split(".").includes(label);
180180
}
181181

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

186187
function isGitLabHost(host: string): boolean {

0 commit comments

Comments
 (0)