Skip to content

Commit 25cc403

Browse files
committed
fix(shared): detect *.ghe.com remotes as GitHub
1 parent ffceb61 commit 25cc403

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
@@ -149,6 +149,22 @@ describe("detectSourceControlProviderFromRemoteUrl", () => {
149149
).toBe("bitbucket");
150150
});
151151

152+
it("detects GitHub Enterprise Cloud data residency hosts on ghe.com", () => {
153+
expect(detectSourceControlProviderFromRemoteUrl("https://acme.ghe.com/owner/repo.git")).toEqual(
154+
{
155+
kind: "github",
156+
name: "GitHub Self-Hosted",
157+
baseUrl: "https://acme.ghe.com",
158+
},
159+
);
160+
expect(detectSourceControlProviderFromRemoteUrl("[email protected]:owner/repo.git")?.kind).toBe(
161+
"github",
162+
);
163+
expect(detectSourceControlProviderFromRemoteUrl("https://ghe.com/owner/repo.git")?.kind).toBe(
164+
"unknown",
165+
);
166+
});
167+
152168
it("does not match provider names embedded in unrelated DNS labels", () => {
153169
expect(
154170
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
@@ -183,8 +183,9 @@ function hasDnsLabel(host: string, label: string): boolean {
183183
return host.split(".").includes(label);
184184
}
185185

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

190191
function isGitLabHost(host: string): boolean {

0 commit comments

Comments
 (0)