mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds Apply Changes command to custom view files
Adds Stash Changes command to SCM view items
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
import { InputBoxOptions, window } from 'vscode';
|
||||
import { InputBoxOptions, Uri, window } from 'vscode';
|
||||
import { GitService } from '../gitService';
|
||||
import { CommandContext } from '../commands';
|
||||
import { Command, Commands } from './common';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem } from '../quickPicks';
|
||||
@@ -8,6 +9,7 @@ import { CommandQuickPickItem } from '../quickPicks';
|
||||
export interface StashSaveCommandArgs {
|
||||
message?: string;
|
||||
unstagedOnly?: boolean;
|
||||
uris?: Uri[];
|
||||
|
||||
goBackCommand?: CommandQuickPickItem;
|
||||
}
|
||||
@@ -18,6 +20,22 @@ export class StashSaveCommand extends Command {
|
||||
super(Commands.StashSave);
|
||||
}
|
||||
|
||||
protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise<any> {
|
||||
if (context.type === 'scm-states') {
|
||||
args = { ...args };
|
||||
args.uris = context.scmResourceStates.map(s => s.resourceUri);
|
||||
return this.execute(args);
|
||||
}
|
||||
|
||||
if (context.type === 'scm-groups') {
|
||||
args = { ...args };
|
||||
args.uris = context.scmResourceGroups.reduce<Uri[]>((a, b) => a.concat(b.resourceStates.map(s => s.resourceUri)), []);
|
||||
return this.execute(args);
|
||||
}
|
||||
|
||||
return this.execute(args);
|
||||
}
|
||||
|
||||
async execute(args: StashSaveCommandArgs = { unstagedOnly: false }) {
|
||||
if (!this.git.repoPath) return undefined;
|
||||
|
||||
@@ -35,7 +53,7 @@ export class StashSaveCommand extends Command {
|
||||
if (args.message === undefined) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
|
||||
}
|
||||
|
||||
return await this.git.stashSave(this.git.repoPath, args.message, args.unstagedOnly);
|
||||
return await this.git.stashSave(this.git.repoPath, args.message, args.uris);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex, 'StashSaveCommand');
|
||||
|
||||
Reference in New Issue
Block a user