Skip to content

Commit 9e23a1d

Browse files
chadhietalaGerrit0
authored andcommitted
1 parent dd15e08 commit 9e23a1d

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/lib/converter/utils/repository.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class Repository {
7171

7272
for (let i = 0, c = repoLinks.length; i < c; i++) {
7373
let match =
74-
/(github(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
74+
/(github(?!.us)(?:\.[a-z]+)*\.[a-z]{2,})[:/]([^/]+)\/(.*)/.exec(
7575
repoLinks[i]
7676
);
7777

@@ -82,6 +82,16 @@ export class Repository {
8282
);
8383
}
8484

85+
// Github Enterprise
86+
if (!match) {
87+
match = /(\w+\.ghe.com)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
88+
}
89+
90+
// Github Enterprise
91+
if (!match) {
92+
match = /(\w+\.github.us)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
93+
}
94+
8595
if (!match) {
8696
match = /(bitbucket.org)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]);
8797
}

src/test/Repository.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@ describe("Repository", function () {
4646
equal(repository.type, RepositoryType.GitHub);
4747
});
4848

49+
it("handles a ghe.com URL", function () {
50+
const mockRemotes = [
51+
"ssh://[email protected]/joebloggs/foobar.git",
52+
];
53+
54+
const repository = new Repository("", "", mockRemotes);
55+
56+
equal(repository.hostname, "bigcompany.ghe.com");
57+
equal(repository.user, "joebloggs");
58+
equal(repository.project, "foobar");
59+
equal(repository.type, RepositoryType.GitHub);
60+
});
61+
62+
it("handles a github.us URL", function () {
63+
const mockRemotes = [
64+
"ssh://[email protected]/joebloggs/foobar.git",
65+
];
66+
67+
const repository = new Repository("", "", mockRemotes);
68+
69+
equal(repository.hostname, "bigcompany.github.us");
70+
equal(repository.user, "joebloggs");
71+
equal(repository.project, "foobar");
72+
equal(repository.type, RepositoryType.GitHub);
73+
});
74+
4975
it("handles a Bitbucket HTTPS URL", function () {
5076
const mockRemotes = [
5177
"https://[email protected]/joebloggs/foobar.git",

0 commit comments

Comments
 (0)