Skip to content

Commit

Permalink
Changes stash save icon
Browse files Browse the repository at this point in the history
Renames existing stash save command
Adds new stash save command (per file)
  • Loading branch information
eamodio committed Dec 19, 2018
1 parent 326eb62 commit 18368ca
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

### Changed

- Renames the _Stash Changes_ command (`gitlens.stashSave`) to _Stash All Changes_ and adds a new _Stash Changes_ command (`gitlens.stashSaveFiles`)
- Changes the icon of the _Stash All Changes_ command (`gitlens.stashSave`) — closes [Microsoft/vscode#64423](https://github.com/Microsoft/vscode/issues/64423)

### Fixed

- Fixes [#598](https://github.com/eamodio/vscode-gitlens/issues/598) — Apply changes when comparing a file from two branches is not working
Expand Down
4 changes: 2 additions & 2 deletions images/dark/icon-stash-save.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions images/light/icon-stash-save.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 22 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,15 @@
},
{
"command": "gitlens.stashSave",
"title": "Stash All Changes",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-stash-save.svg",
"light": "images/light/icon-stash-save.svg"
}
},
{
"command": "gitlens.stashSaveFiles",
"title": "Stash Changes",
"category": "GitLens",
"icon": {
Expand Down Expand Up @@ -2900,6 +2909,10 @@
"command": "gitlens.stashSave",
"when": "gitlens:enabled && !gitlens:readonly"
},
{
"command": "gitlens.stashSaveFiles",
"when": "false"
},
{
"command": "gitlens.resetSuppressedWarnings",
"when": "gitlens:enabled"
Expand Down Expand Up @@ -3504,7 +3517,7 @@
"group": "1_gitlens_1@2"
},
{
"command": "gitlens.stashSave",
"command": "gitlens.stashSaveFiles",
"when": "gitlens:enabled && !gitlens:readonly && config.gitlens.menus.scmItem.stash",
"group": "1_modification@-1"
},
Expand Down Expand Up @@ -3955,7 +3968,7 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.stashSave",
"command": "gitlens.stashSaveFiles",
"when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b.*:(un)?staged\\b/",
"group": "1_gitlens@2"
},
Expand Down Expand Up @@ -4202,24 +4215,24 @@
"when": "viewItem == gitlens:search:results",
"group": "2_gitlens@1"
},
{
"command": "gitlens.stashApply",
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
"group": "inline@98"
},
{
"command": "gitlens.stashSave",
"when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/",
"group": "inline@99"
"group": "inline@98"
},
{
"command": "gitlens.stashApply",
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
"group": "1_gitlens@1"
"group": "inline@99"
},
{
"command": "gitlens.stashSave",
"when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/",
"group": "1_gitlens@1"
},
{
"command": "gitlens.stashApply",
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
"group": "1_gitlens@2"
},
{
Expand Down
9 changes: 9 additions & 0 deletions src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export enum Commands {
StashApply = 'gitlens.stashApply',
StashDelete = 'gitlens.stashDelete',
StashSave = 'gitlens.stashSave',
StashSaveFiles = 'gitlens.stashSaveFiles',
SupportGitLens = 'gitlens.supportGitLens',
SwitchMode = 'gitlens.switchMode',
ToggleCodeLens = 'gitlens.toggleCodeLens',
Expand Down Expand Up @@ -286,6 +287,14 @@ export function isCommandViewContextWithRepo(
return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository;
}

export function isCommandViewContextWithRepoPath(
context: CommandContext
): context is CommandViewItemContext & { node: ViewNode & { repoPath: string } } {
if (context.type !== 'viewItem') return false;

return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string';
}

export type CommandContext =
| CommandScmGroupsContext
| CommandScmStatesContext
Expand Down
9 changes: 7 additions & 2 deletions src/commands/stashSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
Commands,
getRepoPathOrPrompt,
isCommandViewContextWithFile,
isCommandViewContextWithRepo
isCommandViewContextWithRepo,
isCommandViewContextWithRepoPath
} from './common';

export interface StashSaveCommandArgs {
Expand All @@ -27,7 +28,7 @@ export interface StashSaveCommandArgs {
@command()
export class StashSaveCommand extends Command {
constructor() {
super(Commands.StashSave);
super([Commands.StashSave, Commands.StashSaveFiles]);
}

protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise<any> {
Expand All @@ -39,6 +40,10 @@ export class StashSaveCommand extends Command {
args = { ...args };
args.repoPath = context.node.repo.path;
}
else if (isCommandViewContextWithRepoPath(context)) {
args = { ...args };
args.repoPath = context.node.repoPath;
}
else if (context.type === 'scm-states') {
args = { ...args };
args.uris = context.scmResourceStates.map(s => s.resourceUri);
Expand Down

0 comments on commit 18368ca

Please sign in to comment.