You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

45 regels
1.2 KiB

'use strict';
import { GitActions } from '../commands';
import {
command,
Command,
CommandContext,
Commands,
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasRepository,
} from './common';
import { GitStashCommit, GitStashReference } from '../git/git';
import { CommandQuickPickItem } from '../quickpicks';
export interface StashApplyCommandArgs {
deleteAfter?: boolean;
repoPath?: string;
stashItem?: GitStashReference & { message: string };
goBackCommand?: CommandQuickPickItem;
}
@command()
export class StashApplyCommand extends Command {
constructor() {
super(Commands.StashApply);
}
protected preExecute(context: CommandContext, args?: StashApplyCommandArgs) {
if (isCommandContextViewNodeHasCommit<GitStashCommit>(context)) {
args = { ...args, stashItem: context.node.commit };
} else if (isCommandContextViewNodeHasRepository(context)) {
args = { ...args, repoPath: context.node.repo.path };
}
return this.execute(args);
}
async execute(args?: StashApplyCommandArgs) {
if (args?.deleteAfter) {
return GitActions.Stash.pop(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
}
return GitActions.Stash.apply(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
}
}