Adds gitlens.openBranchInRemote command

Adds gitlens.openRepoInRemote command
This commit is contained in:
Eric Amodio
2017-05-22 16:06:45 -04:00
parent 49fa9b5078
commit 6d1a1ca346
9 changed files with 147 additions and 4 deletions

View File

@@ -0,0 +1,37 @@
'use strict';
import { Arrays } from '../system';
import { commands, TextEditor, TextEditorEdit, 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 OpenRepoInRemoteCommand extends ActiveEditorCommand {
constructor(private git: GitService) {
super(Commands.OpenRepoInRemote);
}
async execute(editor: TextEditor, edit: TextEditorEdit, 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: 'repo'
},
remotes
} as OpenInRemoteCommandArgs);
}
catch (ex) {
Logger.error(ex, 'OpenRepoInRemoteCommand');
return window.showErrorMessage(`Unable to open repository in remote provider. See output channel for more details`);
}
}
}