Adds GitLab remote link support

Adds Bitbucket remote link support
Adds Visual Studio Team Services remote link support
This commit is contained in:
Eric Amodio
2017-03-28 01:28:03 -04:00
parent ab417eadbe
commit 851522f593
5 changed files with 80 additions and 3 deletions

View File

@@ -1,12 +1,18 @@
'use strict';
import { RemoteProvider } from './provider';
import { BitbucketService } from './bitbucket';
import { GitHubService } from './github';
import { GitLabService } from './gitlab';
import { VisualStudioService } from './visualStudio';
import { Logger } from '../../logger';
export { RemoteProvider };
const providerMap = new Map<string, (domain: string, path: string) => RemoteProvider>([
['github.com', (domain: string, path: string) => new GitHubService(domain, path)]
['bitbucket.org', (domain: string, path: string) => new BitbucketService(domain, path)],
['github.com', (domain: string, path: string) => new GitHubService(domain, path)],
['gitlab.com', (domain: string, path: string) => new GitLabService(domain, path)],
['visualstudio.com', (domain: string, path: string) => new VisualStudioService(domain, path)]
]);
const UrlRegex = /^(?:git:\/\/(.*?)\/|https:\/\/(.*?)\/|http:\/\/(.*?)\/|git@(.*):\/\/|ssh:\/\/git@(.*?)\/)(.*)$/;
@@ -19,7 +25,11 @@ export class RemoteProviderFactory {
const domain = match[1] || match[2] || match[3] || match[4] || match[5];
const path = match[6].replace(/\.git/, '');
const creator = providerMap.get(domain);
const key = domain.toLowerCase().endsWith('visualstudio.com')
? 'visualstudio.com'
: domain;
const creator = providerMap.get(key.toLowerCase());
if (!creator) return undefined;
return creator(domain, path);