mirror of
https://github.com/argoproj/argo-cd
synced 2026-05-23 09:18:26 +00:00
Adds support for Github Enterprise URLs (#2344)
This commit is contained in:
parent
c4203f7989
commit
706b413353
2 changed files with 18 additions and 4 deletions
|
|
@ -2,9 +2,12 @@ import {repoUrl, revisionUrl} from './urls';
|
|||
|
||||
function testExample(http: string, ssl: string, revision: string, expectedRepoUrl: string, expectedRevisionUrl: string) {
|
||||
expect(repoUrl(http)).toBe(expectedRepoUrl);
|
||||
expect(repoUrl(ssl)).toBe(expectedRepoUrl);
|
||||
expect(revisionUrl(http, revision)).toBe(expectedRevisionUrl);
|
||||
expect(revisionUrl(ssl, revision)).toBe(expectedRevisionUrl);
|
||||
expect(repoUrl(http)).toBe(expectedRepoUrl);
|
||||
expect(revisionUrl(http, revision)).toBe(expectedRevisionUrl);
|
||||
expect(revisionUrl(ssl, revision)).toBe(expectedRevisionUrl);
|
||||
}
|
||||
|
||||
test('github.com', () => {
|
||||
|
|
@ -16,6 +19,15 @@ test('github.com', () => {
|
|||
'https://github.com/argoproj/argo-cd/commit/024dee09f543ce7bb5af7ca50260504d89dfda94');
|
||||
});
|
||||
|
||||
// for enterprise github installations
|
||||
test('github.my-enterprise.com', () => {
|
||||
testExample(
|
||||
'https://github.my-enterprise.com/my-org/my-repo.git',
|
||||
'git@github.my-enterprise.com:my-org/my-repo.git',
|
||||
'a06f2be80a4da89abb8ced904beab75b3ec6db0e',
|
||||
'https://github.my-enterprise.com/my-org/my-repo',
|
||||
'https://github.my-enterprise.com/my-org/my-repo/commit/a06f2be80a4da89abb8ced904beab75b3ec6db0e');
|
||||
});
|
||||
|
||||
test('gitlab.com', () => {
|
||||
testExample(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import {GitUrl} from 'git-url-parse';
|
||||
|
||||
const GitUrlParse = require('git-url-parse');
|
||||
|
||||
function supportedSource(source: string): boolean {
|
||||
return ['github.com', 'gitlab.com', 'bitbucket.org'].indexOf(source) >= 0;
|
||||
function supportedSource(parsed: GitUrl): boolean {
|
||||
return parsed.resource.startsWith('github') || ['gitlab.com', 'bitbucket.org'].indexOf(parsed.source) >= 0;
|
||||
}
|
||||
|
||||
function protocol(proto: string): string {
|
||||
|
|
@ -11,7 +13,7 @@ function protocol(proto: string): string {
|
|||
export function repoUrl(url: string): string {
|
||||
const parsed = GitUrlParse(url);
|
||||
|
||||
if (!supportedSource(parsed.source)) {
|
||||
if (!supportedSource(parsed)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ export function revisionUrl(url: string, revision: string): string {
|
|||
|
||||
const parsed = GitUrlParse(url);
|
||||
|
||||
if (!supportedSource(parsed.source)) {
|
||||
if (!supportedSource(parsed)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue