Files
vscode-gitlens/src/commands/showStashList.ts
2017-07-02 22:32:04 -04:00

30 lines
1.1 KiB
TypeScript

'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand, getCommandUri } from './common';
import { StashExplorer } from '../views/stashExplorer';
import { GitService, GitUri } from '../gitService';
import { Messages } from '../messages';
import { Logger } from '../logger';
export class ShowStashListCommand extends EditorCommand {
constructor(private git: GitService, private explorer: StashExplorer) {
super(Commands.ShowStashList);
}
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri) {
uri = getCommandUri(uri, editor);
try {
const repoPath = await this.git.getRepoPathFromUri(uri);
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show stashed changes`);
this.explorer.update(new GitUri(uri, { repoPath: repoPath, fileName: uri!.fsPath }));
return undefined;
}
catch (ex) {
Logger.error(ex, 'ShowStashListCommand');
return window.showErrorMessage(`Unable to show stash list. See output channel for more details`);
}
}
}