mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-10 10:12:40 -05:00
Adapts stash commands to new structure for views
Adds onDidChangeRepo event to GitService Refreshes stash view when repo changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
import { MessageItem, window } from 'vscode';
|
||||
import { Command, Commands } from './common';
|
||||
import { Command, CommandContext, Commands } from './common';
|
||||
import { GlyphChars } from '../constants';
|
||||
import { GitService } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
@@ -20,17 +20,22 @@ export class StashDeleteCommand extends Command {
|
||||
super(Commands.StashDelete);
|
||||
}
|
||||
|
||||
async execute(args: StashDeleteCommandArgs | StashCommitNode = { confirm: true }) {
|
||||
if (!this.git.repoPath) return undefined;
|
||||
let stashCommitNode = undefined;
|
||||
if (args instanceof StashCommitNode) {
|
||||
stashCommitNode = args;
|
||||
args = {
|
||||
confirm: true,
|
||||
stashItem: args.commit
|
||||
};
|
||||
protected async preExecute(context: CommandContext, args: StashDeleteCommandArgs = { confirm: true }) {
|
||||
if (context.type === 'view' && context.node instanceof StashCommitNode) {
|
||||
args = { ...args };
|
||||
|
||||
const stash = context.node.commit;
|
||||
args.stashItem = { stashName: stash.stashName, message: stash.message };
|
||||
|
||||
return this.execute(args);
|
||||
}
|
||||
|
||||
return super.preExecute(context, args);
|
||||
}
|
||||
|
||||
async execute(args: StashDeleteCommandArgs = { confirm: true }) {
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
args = { ...args };
|
||||
if (args.stashItem === undefined || args.stashItem.stashName === undefined) return undefined;
|
||||
|
||||
@@ -45,11 +50,7 @@ export class StashDeleteCommand extends Command {
|
||||
if (result === undefined || result.title !== 'Yes') return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
|
||||
}
|
||||
|
||||
const ret = await this.git.stashDelete(this.git.repoPath, args.stashItem.stashName);
|
||||
if (stashCommitNode) {
|
||||
stashCommitNode.refreshNode();
|
||||
}
|
||||
return ret;
|
||||
return await this.git.stashDelete(this.git.repoPath, args.stashItem.stashName);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex, 'StashDeleteCommand');
|
||||
|
||||
Reference in New Issue
Block a user