mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-16 09:35:40 -05:00
Renames hosting to remote
This commit is contained in:
31
src/commands/openFileInRemote.ts
Normal file
31
src/commands/openFileInRemote.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
import { Arrays } from '../system';
|
||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands } from './commands';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
|
||||
export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService, private repoPath: string) {
|
||||
super(Commands.OpenFileInRemote);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
if (!editor || !editor.document) return undefined;
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), gitUri.sha]);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenFileInRemoteCommand]', ex);
|
||||
return window.showErrorMessage(`Unable to open file in remote provider. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user