mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 01:35:37 -05:00
Uses current branch when opening remote file
Adds current branch name to quick pick description
This commit is contained in:
@@ -19,8 +19,9 @@ export class GitHubService extends RemoteProvider {
|
||||
return `${this.baseUrl}/commit/${sha}`;
|
||||
}
|
||||
|
||||
protected getUrlForFile(fileName: string, sha?: string): string {
|
||||
protected getUrlForFile(fileName: string, branch?: string, sha?: string): string {
|
||||
if (sha) return `${this.baseUrl}/blob/${sha}/${fileName}`;
|
||||
if (branch) return `${this.baseUrl}/blob/${branch}/${fileName}`;
|
||||
return `${this.baseUrl}?path=${fileName}`;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
import { commands, Uri } from 'vscode';
|
||||
import { BuiltInCommands } from '../../constants';
|
||||
|
||||
export type RemoteProviderOpenType = 'branch' | 'commit' | 'file';
|
||||
export type RemoteOpenType = 'branch' | 'commit' | 'file' | 'working-file';
|
||||
|
||||
export abstract class RemoteProvider {
|
||||
|
||||
@@ -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, sha?: string): string;
|
||||
protected abstract getUrlForFile(fileName: string, branch: string, sha?: string): string;
|
||||
|
||||
private async _openUrl(url: string): Promise<{}> {
|
||||
return url && commands.executeCommand(BuiltInCommands.Open, Uri.parse(url));
|
||||
@@ -24,13 +24,17 @@ export abstract class RemoteProvider {
|
||||
|
||||
open(type: 'branch', branch: string): Promise<{}>;
|
||||
open(type: 'commit', sha: string): Promise<{}>;
|
||||
open(type: 'file', fileName: string, sha?: string): Promise<{}>;
|
||||
open(type: RemoteProviderOpenType, ...args: string[]): Promise<{}>;
|
||||
open(type: RemoteProviderOpenType, branchOrShaOrFileName: string, 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<{}> {
|
||||
switch (type) {
|
||||
case 'branch': return this.openBranch(branchOrShaOrFileName);
|
||||
case 'commit': return this.openCommit(branchOrShaOrFileName);
|
||||
case 'file': return this.openFile(branchOrShaOrFileName, sha);
|
||||
case 'branch':
|
||||
return this.openBranch(branchOrShaOrFileName);
|
||||
case 'commit':
|
||||
return this.openCommit(branchOrShaOrFileName);
|
||||
case 'file':
|
||||
case 'working-file':
|
||||
return this.openFile(branchOrShaOrFileName, fileBranch, fileSha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +46,7 @@ export abstract class RemoteProvider {
|
||||
return this._openUrl(this.getUrlForCommit(sha));
|
||||
}
|
||||
|
||||
openFile(fileName: string, sha?: string) {
|
||||
return this._openUrl(this.getUrlForFile(fileName, sha));
|
||||
openFile(fileName: string, branch?: string, sha?: string) {
|
||||
return this._openUrl(this.getUrlForFile(fileName, branch, sha));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user