Adds experimental 'Stash Changes' command

Adds experimental 'Stash Changes' to stash list
Adds experimental 'Stash Unstaged Changes' to stash list
This commit is contained in:
Eric Amodio
2017-03-29 01:31:31 -04:00
parent e3c9fd53ca
commit d8564c215c
11 changed files with 83 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ export const Commands = {
ShowQuickStashList: 'gitlens.showQuickStashList' as Commands,
StashApply: 'gitlens.stashApply' as Commands,
StashDelete: 'gitlens.stashDelete' as Commands,
StashSave: 'gitlens.stashSave' as Commands,
ToggleBlame: 'gitlens.toggleBlame' as Commands,
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
};

View File

@@ -21,7 +21,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
if (!repoPath) return window.showWarningMessage(`Unable to show stashed changes`);
const stash = await this.git.getStashList(repoPath);
const pick = await StashListQuickPick.show(stash, undefined, goBackCommand);
const pick = await StashListQuickPick.show(this.git, stash, 'list', goBackCommand);
if (!pick) return undefined;
if (pick instanceof CommandQuickPickItem) {

View File

@@ -18,7 +18,7 @@ export class StashApplyCommand extends Command {
const stash = await this.git.getStashList(this.git.repoPath);
if (!stash) return window.showInformationMessage(`There are no stashed changes`);
const pick = await StashListQuickPick.show(stash, 'Apply stashed changes to your working tree\u2026');
const pick = await StashListQuickPick.show(this.git, stash, 'apply');
if (!pick || !(pick instanceof CommitQuickPickItem)) return undefined;
stashItem = pick.commit as GitStashCommit;

32
src/commands/stashSave.ts Normal file
View File

@@ -0,0 +1,32 @@
'use strict';
import { InputBoxOptions, window } from 'vscode';
import { GitService } from '../gitService';
import { Command, Commands } from './common';
import { Logger } from '../logger';
export class StashSaveCommand extends Command {
constructor(private git: GitService) {
super(Commands.StashSave);
}
async execute(message?: string, unstagedOnly: boolean = false) {
if (!this.git.config.insiders) return undefined;
try {
if (message == null) {
message = await window.showInputBox({
prompt: `Please provide a stash message`,
placeHolder: `Stash message`
} as InputBoxOptions);
if (message === undefined) return undefined;
}
return await this.git.stashSave(this.git.repoPath, message, unstagedOnly);
}
catch (ex) {
Logger.error(ex, 'StashSaveCommand');
return window.showErrorMessage(`Unable to save stash. See output channel for more details`);
}
}
}