|
|
@ -1,5 +1,5 @@ |
|
|
|
'use strict'; |
|
|
|
import { commands, Uri } from 'vscode'; |
|
|
|
import { commands, Range, Uri } from 'vscode'; |
|
|
|
import { BuiltInCommands } from '../../constants'; |
|
|
|
|
|
|
|
export type RemoteOpenType = 'branch' | 'commit' | 'file' | 'working-file'; |
|
|
@ -16,7 +16,7 @@ export abstract class RemoteProvider { |
|
|
|
|
|
|
|
protected abstract getUrlForBranch(branch: string): string; |
|
|
|
protected abstract getUrlForCommit(sha: string): string; |
|
|
|
protected abstract getUrlForFile(fileName: string, branch: string, sha?: string): string; |
|
|
|
protected abstract getUrlForFile(fileName: string, branch: string, sha?: string, range?: Range): string; |
|
|
|
|
|
|
|
private async _openUrl(url: string): Promise<{}> { |
|
|
|
return url && commands.executeCommand(BuiltInCommands.Open, Uri.parse(url)); |
|
|
@ -24,9 +24,9 @@ export abstract class RemoteProvider { |
|
|
|
|
|
|
|
open(type: 'branch', branch: string): Promise<{}>; |
|
|
|
open(type: 'commit', sha: string): Promise<{}>; |
|
|
|
open(type: 'file', fileName: string, branch?: string, sha?: string): Promise<{}>; |
|
|
|
open(type: RemoteOpenType, ...args: string[]): Promise<{}>; |
|
|
|
open(type: RemoteOpenType, branchOrShaOrFileName: string, fileBranch?: string, fileSha?: string): Promise<{}> { |
|
|
|
open(type: 'file', fileName: string, branch?: string, sha?: string, range?: Range): Promise<{}>; |
|
|
|
open(type: RemoteOpenType, ...args: any[]): Promise<{}>; |
|
|
|
open(type: RemoteOpenType, branchOrShaOrFileName: string, fileBranch?: string, fileSha?: string, fileRange?: Range): Promise<{}> { |
|
|
|
switch (type) { |
|
|
|
case 'branch': |
|
|
|
return this.openBranch(branchOrShaOrFileName); |
|
|
@ -34,7 +34,7 @@ export abstract class RemoteProvider { |
|
|
|
return this.openCommit(branchOrShaOrFileName); |
|
|
|
case 'file': |
|
|
|
case 'working-file': |
|
|
|
return this.openFile(branchOrShaOrFileName, fileBranch, fileSha); |
|
|
|
return this.openFile(branchOrShaOrFileName, fileBranch, fileSha, fileRange); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -46,7 +46,7 @@ export abstract class RemoteProvider { |
|
|
|
return this._openUrl(this.getUrlForCommit(sha)); |
|
|
|
} |
|
|
|
|
|
|
|
openFile(fileName: string, branch?: string, sha?: string) { |
|
|
|
return this._openUrl(this.getUrlForFile(fileName, branch, sha)); |
|
|
|
openFile(fileName: string, branch?: string, sha?: string, range?: Range) { |
|
|
|
return this._openUrl(this.getUrlForFile(fileName, branch, sha, range)); |
|
|
|
} |
|
|
|
} |