mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 17:25:33 -05:00
Renames hosting to remote
This commit is contained in:
@@ -10,7 +10,7 @@ export * from './models/models';
|
||||
export * from './parsers/blameParser';
|
||||
export * from './parsers/logParser';
|
||||
export * from './parsers/statusParser';
|
||||
export * from './hosting/hostingProvider';
|
||||
export * from './remotes/provider';
|
||||
|
||||
let git: IGit;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { HostingProvider, HostingProviderFactory } from '../hosting/factory';
|
||||
import { RemoteProvider, RemoteProviderFactory } from '../remotes/factory';
|
||||
|
||||
export type GitRemoteType = 'fetch' | 'push';
|
||||
|
||||
@@ -9,7 +9,7 @@ export class GitRemote {
|
||||
url: string;
|
||||
type: GitRemoteType;
|
||||
|
||||
provider?: HostingProvider;
|
||||
provider?: RemoteProvider;
|
||||
|
||||
constructor(remote: string) {
|
||||
remote = remote.trim();
|
||||
@@ -22,6 +22,6 @@ export class GitRemote {
|
||||
|
||||
this.type = typeInfo.substring(1, typeInfo.length - 1) as GitRemoteType;
|
||||
|
||||
this.provider = HostingProviderFactory.getHostingProvider(this.url);
|
||||
this.provider = RemoteProviderFactory.getRemoteProvider(this.url);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
'use strict';
|
||||
import { HostingProvider } from './hostingProvider';
|
||||
import { RemoteProvider } from './provider';
|
||||
import { GitHubService } from './github';
|
||||
import { Logger } from '../../logger';
|
||||
|
||||
export { HostingProvider };
|
||||
export { RemoteProvider };
|
||||
|
||||
const serviceMap = new Map<string, (domain: string, path: string) => HostingProvider>([
|
||||
const providerMap = new Map<string, (domain: string, path: string) => RemoteProvider>([
|
||||
['github.com', (domain: string, path: string) => new GitHubService(domain, path)]
|
||||
]);
|
||||
|
||||
const UrlRegex = /^(?:git:\/\/(.*?)\/|https:\/\/(.*?)\/|http:\/\/(.*?)\/|git@(.*):\/\/|ssh:\/\/git@(.*?)\/)(.*)$/;
|
||||
|
||||
export class HostingProviderFactory {
|
||||
export class RemoteProviderFactory {
|
||||
|
||||
static getHostingProvider(url: string): HostingProvider {
|
||||
static getRemoteProvider(url: string): RemoteProvider {
|
||||
try {
|
||||
const match = UrlRegex.exec(url);
|
||||
const domain = match[1] || match[2] || match[3] || match[4] || match[5];
|
||||
const path = match[6].replace(/\.git/, '');
|
||||
|
||||
const serviceCreator = serviceMap.get(domain);
|
||||
if (!serviceCreator) return undefined;
|
||||
const creator = providerMap.get(domain);
|
||||
if (!creator) return undefined;
|
||||
|
||||
return serviceCreator(domain, path);
|
||||
return creator(domain, path);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex);
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
import { HostingProvider } from './hostingProvider';
|
||||
import { RemoteProvider } from './provider';
|
||||
|
||||
export class GitHubService extends HostingProvider {
|
||||
export class GitHubService extends RemoteProvider {
|
||||
|
||||
constructor(public domain: string, public path: string) {
|
||||
super(domain, path);
|
||||
@@ -2,9 +2,9 @@
|
||||
import { commands, Uri } from 'vscode';
|
||||
import { BuiltInCommands } from '../../constants';
|
||||
|
||||
export type HostingProviderOpenType = 'branch' | 'commit' | 'file';
|
||||
export type RemoteProviderOpenType = 'branch' | 'commit' | 'file';
|
||||
|
||||
export abstract class HostingProvider {
|
||||
export abstract class RemoteProvider {
|
||||
|
||||
constructor(public domain: string, public path: string) { }
|
||||
|
||||
@@ -25,8 +25,8 @@ export abstract class HostingProvider {
|
||||
open(type: 'branch', branch: string): Promise<{}>;
|
||||
open(type: 'commit', sha: string): Promise<{}>;
|
||||
open(type: 'file', fileName: string, sha?: string): Promise<{}>;
|
||||
open(type: HostingProviderOpenType, ...args: string[]): Promise<{}>;
|
||||
open(type: HostingProviderOpenType, branchOrShaOrFileName: string, sha?: string): Promise<{}> {
|
||||
open(type: RemoteProviderOpenType, ...args: string[]): Promise<{}>;
|
||||
open(type: RemoteProviderOpenType, branchOrShaOrFileName: string, sha?: string): Promise<{}> {
|
||||
switch (type) {
|
||||
case 'branch': return this.openBranch(branchOrShaOrFileName);
|
||||
case 'commit': return this.openCommit(branchOrShaOrFileName);
|
||||
Reference in New Issue
Block a user