From a0a127f47648ccfa1497e14e8b4c375074b38e87 Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Tue, 19 Oct 2021 09:54:47 -0700 Subject: [PATCH] Support githubprivate.com in GitHubPlugin --- src/lib/converter/plugins/GitHubPlugin.ts | 7 +++++++ src/test/GitHubPlugin.test.ts | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/lib/converter/plugins/GitHubPlugin.ts b/src/lib/converter/plugins/GitHubPlugin.ts index ba598a5da..bc32ea927 100644 --- a/src/lib/converter/plugins/GitHubPlugin.ts +++ b/src/lib/converter/plugins/GitHubPlugin.ts @@ -72,6 +72,13 @@ export class Repository { repoLinks[i] ); + // Github Enterprise + if (!match) { + match = /(\w+\.githubprivate.com)[:/]([^/]+)\/(.*)/.exec( + repoLinks[i] + ); + } + if (!match) { match = /(bitbucket.org)[:/]([^/]+)\/(.*)/.exec(repoLinks[i]); } diff --git a/src/test/GitHubPlugin.test.ts b/src/test/GitHubPlugin.test.ts index 22778419a..6616f1ef5 100644 --- a/src/test/GitHubPlugin.test.ts +++ b/src/test/GitHubPlugin.test.ts @@ -33,6 +33,19 @@ describe("Repository", function () { equal(repository.type, RepositoryType.GitHub); }); + it("handles a githubprivate.com URL", function () { + const mockRemotes = [ + "ssh://org@bigcompany.githubprivate.com/joebloggs/foobar.git", + ]; + + const repository = new github.Repository("", "", mockRemotes); + + equal(repository.hostname, "bigcompany.githubprivate.com"); + equal(repository.user, "joebloggs"); + equal(repository.project, "foobar"); + equal(repository.type, RepositoryType.GitHub); + }); + it("handles a Bitbucket HTTPS URL", function () { const mockRemotes = [ "https://joebloggs@bitbucket.org/joebloggs/foobar.git",