mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 01:35:36 -05:00
Adds Open Branches in Remote command
Adds Open Branches in Remote command to the Branches custom view item Adds Open Repository in Remote command to the Repository Status custom view item
This commit is contained in:
@@ -19,6 +19,7 @@ export type Commands =
|
||||
'gitlens.diffWithWorking' |
|
||||
'gitlens.diffLineWithWorking' |
|
||||
'gitlens.openChangedFiles' |
|
||||
'gitlens.openBranchesInRemote' |
|
||||
'gitlens.openBranchInRemote' |
|
||||
'gitlens.openCommitInRemote' |
|
||||
'gitlens.openFileInRemote' |
|
||||
@@ -59,6 +60,7 @@ export const Commands = {
|
||||
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
|
||||
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
|
||||
OpenChangedFiles: 'gitlens.openChangedFiles' as Commands,
|
||||
OpenBranchesInRemote: 'gitlens.openBranchesInRemote' as Commands,
|
||||
OpenBranchInRemote: 'gitlens.openBranchInRemote' as Commands,
|
||||
OpenCommitInRemote: 'gitlens.openCommitInRemote' as Commands,
|
||||
OpenFileInRemote: 'gitlens.openFileInRemote' as Commands,
|
||||
|
||||
37
src/commands/openBranchesInRemote.ts
Normal file
37
src/commands/openBranchesInRemote.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
import { Arrays } from '../system';
|
||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { OpenInRemoteCommandArgs } from './openInRemote';
|
||||
|
||||
export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenBranchesInRemote);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri) {
|
||||
uri = getCommandUri(uri, editor);
|
||||
|
||||
const gitUri = uri && await GitUri.fromUri(uri, this.git);
|
||||
|
||||
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
|
||||
if (!repoPath) return undefined;
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), _ => _.url, _ => !!_.provider);
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||
resource: {
|
||||
type: 'branches'
|
||||
},
|
||||
remotes
|
||||
} as OpenInRemoteCommandArgs);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex, 'OpenBranchesInRemoteCommand');
|
||||
return window.showErrorMessage(`Unable to open branches in remote provider. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user