mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 17:25:51 -05:00
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:
@@ -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
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
32
src/commands/stashSave.ts
Normal 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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user