Skip to content

Commit

Permalink
Closes #569 - Adds directory compare with head command
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 5, 2018
1 parent 532b9c0 commit 1fc6ac3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Adds a _Directory Compare All Changes_ (`gitlens.diffDirectoryWithHead`) command to open the configured git difftool to compare the working directory with HEAD — closes [#569](https://github.com/eamodio/vscode-gitlens/issues/569)

### Changed

- Renames _Open Changes (with difftool)_ command to _Open All Changes (with difftool)_ when shown on the SCM group context menu

## [9.0.1] - 2018-12-02

### Fixed
Expand Down
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,11 @@
"title": "Directory Compare Working Tree with...",
"category": "GitLens"
},
{
"command": "gitlens.diffDirectoryWithHead",
"title": "Directory Compare All Changes",
"category": "GitLens"
},
{
"command": "gitlens.diffHeadWithBranch",
"title": "Compare HEAD with Branch or Tag...",
Expand Down Expand Up @@ -2586,6 +2591,10 @@
"command": "gitlens.diffDirectory",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffDirectoryWithHead",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffHeadWithBranch",
"when": "gitlens:enabled"
Expand Down Expand Up @@ -3319,14 +3328,19 @@
"group": "2_gitlens@2"
},
{
"command": "gitlens.externalDiff",
"command": "gitlens.externalDiffAll",
"when": "gitlens:enabled",
"group": "2_gitlens@3"
"group": "3_gitlens@3"
},
{
"command": "gitlens.diffDirectoryWithHead",
"when": "gitlens:enabled",
"group": "3_gitlens@4"
},
{
"command": "gitlens.stashSave",
"when": "gitlens:enabled && !gitlens:readonly",
"group": "3_gitlens@1"
"group": "4_gitlens@1"
}
],
"scm/resourceState/context": [
Expand Down
1 change: 1 addition & 0 deletions src/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum Commands {
CopyRemoteFileUrlToClipboard = 'gitlens.copyRemoteFileUrlToClipboard',
CopyShaToClipboard = 'gitlens.copyShaToClipboard',
DiffDirectory = 'gitlens.diffDirectory',
DiffDirectoryWithHead = 'gitlens.diffDirectoryWithHead',
DiffHeadWithBranch = 'gitlens.diffHeadWithBranch',
DiffWorkingWithBranch = 'gitlens.diffWorkingWithBranch',
ExternalDiffAll = 'gitlens.externalDiffAll',
Expand Down
12 changes: 11 additions & 1 deletion src/commands/diffDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ export interface DiffDirectoryCommandArgs {
@command()
export class DiffDirectoryCommand extends ActiveEditorCommand {
constructor() {
super([Commands.DiffDirectory, Commands.ViewsOpenDirectoryDiff, Commands.ViewsOpenDirectoryDiffWithWorking]);
super([
Commands.DiffDirectory,
Commands.DiffDirectoryWithHead,
Commands.ViewsOpenDirectoryDiff,
Commands.ViewsOpenDirectoryDiffWithWorking
]);
}

protected async preExecute(context: CommandContext, args: DiffDirectoryCommandArgs = {}): Promise<any> {
switch (context.command) {
case Commands.DiffDirectoryWithHead:
args.ref1 = 'HEAD';
args.ref2 = undefined;
break;

case Commands.ViewsOpenDirectoryDiff:
if (context.type === 'viewItem' && context.node instanceof CompareResultsNode) {
args.ref1 = context.node.ref1.ref;
Expand Down
16 changes: 7 additions & 9 deletions src/commands/externalDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ export class ExternalDiffCommand extends Command {
}
else if (context.type === 'scm-groups') {
args = { ...args };
args.files = Arrays.filterMap(
context.scmResourceGroups[0].resourceStates,
r =>
this.isModified(r)
? {
uri: r.resourceUri,
staged: (r as Resource).resourceGroupType === ResourceGroupType.Index
}
: undefined
args.files = Arrays.filterMap(context.scmResourceGroups[0].resourceStates, r =>
this.isModified(r)
? {
uri: r.resourceUri,
staged: (r as Resource).resourceGroupType === ResourceGroupType.Index
}
: undefined
);
}
}
Expand Down

0 comments on commit 1fc6ac3

Please sign in to comment.