Adds 'Show Stashed Changes` command

Adds experimental 'Apply Stashed Changes' command
Adds experimental 'Delete Stashed Changes' to stashed changes quick pick
This commit is contained in:
Eric Amodio
2017-03-28 18:43:33 -04:00
parent 19fe22f061
commit 9945ee6d94
21 changed files with 566 additions and 137 deletions

View File

@@ -0,0 +1,31 @@
'use strict';
import { MessageItem, window } from 'vscode';
import { GitService } from '../gitService';
import { Command, Commands } from './common';
import { Logger } from '../logger';
export class StashDeleteCommand extends Command {
constructor(private git: GitService) {
super(Commands.StashDelete);
}
async execute(stashItem: { stashName: string, message: string }, confirm: boolean = true) {
if (!this.git.config.insiders) return undefined;
if (!stashItem || !stashItem.stashName) return undefined;
try {
if (confirm) {
const message = stashItem.message.length > 80 ? `${stashItem.message.substring(0, 80)}\u2026` : stashItem.message;
const result = await window.showWarningMessage(`Delete stashed changes '${message}'?`, { title: 'Yes' } as MessageItem, { title: 'No', isCloseAffordance: true } as MessageItem);
if (!result || result.title !== 'Yes') return undefined;
}
return await this.git.stashDelete(this.git.repoPath, stashItem.stashName);
}
catch (ex) {
Logger.error(ex, 'StashDeleteCommand');
return window.showErrorMessage(`Unable to delete stash. See output channel for more details`);
}
}
}