瀏覽代碼

Closes #234 - adds directory compare to views

main
Eric Amodio 7 年之前
父節點
當前提交
9dc6e29a49
共有 8 個檔案被更改,包括 103 行新增42 行删除
  1. +6
    -3
      CHANGELOG.md
  2. +7
    -7
      README.md
  3. +44
    -1
      package.json
  4. +7
    -5
      src/commands/common.ts
  5. +29
    -16
      src/commands/diffDirectory.ts
  6. +3
    -3
      src/gitService.ts
  7. +5
    -5
      src/quickPicks/commitDetails.ts
  8. +2
    -2
      src/views/comparisionResultsNode.ts

+ 6
- 3
CHANGELOG.md 查看文件

@ -10,13 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Automatically updates to track the repository of the active editor
- Only visible if there is more than 1 repository within the workspace
- Adds a new `Tags` node to the `Repository View` of the `GitLens` view
- Adds a new `Tags` node to the `Repository View` of the `GitLens` view -- closes [#234](https://github.com/eamodio/vscode-gitlens/issues/234)
- Provides a list of tags
- Expand each tag to easily see its revision (commit) history
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, and `Refresh` commands
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, `Open Directory Compare with Working Tree`, and `Refresh` commands
- Provides a context menu with a `Refresh` command
- Adds [Gravatar](https://en.gravatar.com/) support to the `GitLens` view
@ -43,7 +43,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `Changed Files` node — provides a list of all the files changed between the compared revisions (branches or commits)
- Expands to a file-based view of all changed files
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides a context menu with `Open Directory Compare` and `Refresh` commands
- Provides toolbar commands to `Search Commits`, `Keep Results`, `Refresh`, `Show Files in Automatic View` or `Show Files in List View` or `Show Files in Tree View`, and `Close`
- Adds `Apply Changes` option to the commit/stash file quick pick menu -- closes [#232](https://github.com/eamodio/vscode-gitlens/issues/232)
@ -53,6 +53,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed
- Improves startup performance a bit
- Renames `Compare Directory with Branch...` command (`gitlens.diffDirectory`) to `Directory Compare Working Tree with...`
- Renames `Compare Directory with Previous Revision` in quick pick menus to `Open Directory Compare with Previous Revision`
- Renames `Compare Directory with Working Tree` in quick pick menus to `Open Directory Compare with Working Tree`
### Fixed
- Fixes [#228](https://github.com/eamodio/vscode-gitlens/issues/228) - Gutter blame spills over heatmap

+ 7
- 7
README.md 查看文件

@ -160,7 +160,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides a context menu on each branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Open Directory Compare with Working Tree`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu with `Open Branches in Remote`, and `Refresh` commands
- `Remotes` node — provides a list of remotes
@ -170,7 +170,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`,`Show Commit Details`, `Compare with Selected`, `Select for Compare`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, `Show File History`, and `Show Commit File Details` commands
- Provides a context menu on each remote branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each remote branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Open Directory Compare with Working Tree`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, `Remove Remote (via Terminal)`, and `Refresh` commands
- Provides a context menu with a `Refresh` command
@ -185,7 +185,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, and `Refresh` commands
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, `Open Directory Compare with Working Tree`, and `Refresh` commands
- Provides a context menu with a `Refresh` command
- `History View` - provides the revision history of the active file
@ -223,7 +223,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- `Changed Files` node — provides a list of all the files changed between the compared revisions (branches or commits)
- Expands to a file-based view of all changed files
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides a context menu with `Open Directory Compare` and `Refresh` commands
- Provides toolbar commands to `Search Commits`, `Keep Results`, `Refresh`, `Show Files in Automatic View` or `Show Files in List View` or `Show Files in Tree View`, and `Close`
- Adds commands to open files, commits, branches, and the repository in the supported remote services, **BitBucket, GitHub, GitLab, and Visual Studio Team Services** or a [**user-defined** remote services](#custom-remotes-settings) — only available if a Git upstream service is configured in the repository
@ -258,7 +258,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Commit Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-commit-details.png)
- Quickly see the set of files changed in the commit, complete with status indicators for adds, changes, renames, and deletes
- Provides additional entries to `Open Commit in <remote-service>` when available, `Open Files`, `Open Revisions`, `Compare Directory with Previous Revision`, `Compare Directory with Working Tree`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`
- Provides additional entries to `Open Commit in <remote-service>` when available, `Open Files`, `Open Revisions`, `Open Directory Compare with Previous Revision`, `Open Directory Compare with Working Tree`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#extension-settings) is set
- Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one
@ -295,7 +295,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Stash Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-stash-details.png)
- Quickly see the set of files changed in the stash, complete with status indicators for adds, changes, renames, and deletes
- Provides additional entries to `Apply Stashed Changes` (requires confirmation), `Delete Stashed Changes` (requires confirmation), `Open Files`, `Open Revisions`, `Compare Directory with Previous Revision`, `Compare Directory with Working Tree`, `Copy Commit Message to Clipboard`
- Provides additional entries to `Apply Stashed Changes` (requires confirmation), `Delete Stashed Changes` (requires confirmation), `Open Files`, `Open Revisions`, `Open Directory Compare with Previous Revision`, `Open Directory Compare with Working Tree`, `Copy Commit Message to Clipboard`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#extension-settings) is set
- Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one
@ -308,7 +308,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- Provides easy access to the following comparison commands via the `Command Palette` as well as in context via the many provided quick pick menus
- Adds a `Compare Directory with Branch...` command (`gitlens.diffDirectory`) to open the configured Git difftool to compare directories between branches
- Adds a `Directory Compare Working Tree with...` command (`gitlens.diffDirectory`) to open the configured Git difftool to compare the working tree with the selected branch
- Adds a `Compare File with Branch...` command (`gitlens.diffWithBranch`) to compare the active file with the same file on the selected branch

+ 44
- 1
package.json 查看文件

@ -1137,7 +1137,7 @@
"commands": [
{
"command": "gitlens.diffDirectory",
"title": "Compare Directory with Branch...",
"title": "Directory Compare Working Tree with...",
"category": "GitLens"
},
{
@ -1365,6 +1365,16 @@
"category": "GitLens"
},
{
"command": "gitlens.explorers.openDirectoryDiff",
"title": "Open Directory Compare",
"category": "GitLens"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"title": "Open Directory Compare with Working Tree",
"category": "GitLens"
},
{
"command": "gitlens.explorers.openChanges",
"title": "Open Changes",
"category": "GitLens"
@ -1742,6 +1752,14 @@
"when": "false"
},
{
"command": "gitlens.explorers.openDirectoryDiff",
"when": "false"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"when": "false"
},
{
"command": "gitlens.explorers.openChangesWithWorking",
"when": "false"
},
@ -2207,6 +2225,11 @@
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"when": "viewItem == gitlens:branch",
"group": "7_gitlens_diff@1"
},
{
"command": "gitlens.explorers.terminalCheckoutBranch",
"when": "viewItem == gitlens:branch",
"group": "8_gitlens@1"
@ -2242,6 +2265,11 @@
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens_diff@1"
},
{
"command": "gitlens.explorers.terminalCheckoutBranch",
"when": "viewItem == gitlens:branch:tracking",
"group": "8_gitlens@1"
@ -2317,6 +2345,11 @@
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"when": "viewItem == gitlens:remote-branch",
"group": "7_gitlens_diff@1"
},
{
"command": "gitlens.explorers.terminalCheckoutBranch",
"when": "viewItem == gitlens:remote-branch",
"group": "8_gitlens@1"
@ -2527,6 +2560,11 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.openDirectoryDiff",
"when": "viewItem == gitlens:comparison-results",
"group": "7_gitlens@1"
},
{
"command": "gitlens.resultsExplorer.clearResultsNode",
"when": "viewItem == gitlens:search-results",
"group": "1_gitlens@1"
@ -2682,6 +2720,11 @@
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
"when": "viewItem == gitlens:tag",
"group": "7_gitlens_diff@1"
},
{
"command": "gitlens.gitExplorer.refreshNode",
"when": "view == gitlens.gitExplorer && viewItem != gitlens:commit-file && viewItem != gitlens:stash-file && viewItem != gitlens:status-file",
"group": "9_gitlens@1"

+ 7
- 5
src/commands/common.ts 查看文件

@ -1,6 +1,6 @@
'use strict';
import { commands, Disposable, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
import { ExplorerNode } from '../views/explorerNodes';
import { ExplorerNode, ExplorerRefNode } from '../views/explorerNodes';
import { GitBranch, GitCommit, GitRemote, GitUri } from '../gitService';
import { Logger } from '../logger';
import { Telemetry } from '../telemetry';
@ -21,6 +21,8 @@ export enum Commands {
DiffWithWorking = 'gitlens.diffWithWorking',
DiffLineWithWorking = 'gitlens.diffLineWithWorking',
ExternalDiff = 'gitlens.externalDiff',
ExplorersOpenDirectoryDiff = 'gitlens.explorers.openDirectoryDiff',
ExplorersOpenDirectoryDiffWithWorking = 'gitlens.explorers.openDirectoryDiffWithWorking',
OpenChangedFiles = 'gitlens.openChangedFiles',
OpenBranchesInRemote = 'gitlens.openBranchesInRemote',
OpenBranchInRemote = 'gitlens.openBranchInRemote',
@ -94,12 +96,12 @@ export function isCommandViewContextWithBranch(context: CommandContext): context
return context.type === 'view' && (context.node as any).branch && (context.node as any).branch instanceof GitBranch;
}
interface ICommandViewContextWithCommit<T extends GitCommit> extends CommandViewContext {
node: (ExplorerNode & { commit: T });
export function isCommandViewContextWithCommit<T extends GitCommit>(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { commit: T }) } {
return context.type === 'view' && (context.node as any).commit && (context.node as any).commit instanceof GitCommit;
}
export function isCommandViewContextWithCommit<T extends GitCommit>(context: CommandContext): context is ICommandViewContextWithCommit<T> {
return context.type === 'view' && (context.node as any).commit && (context.node as any).commit instanceof GitCommit;
export function isCommandViewContextWithRef(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { ref: string }) } {
return context.type === 'view' && (context.node instanceof ExplorerRefNode);
}
export function isCommandViewContextWithRemote(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { remote: GitRemote }) } {

+ 29
- 16
src/commands/diffDirectory.ts 查看文件

@ -1,17 +1,17 @@
'use strict';
import { Iterables } from '../system';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { CommandContext } from '../commands';
import { CommandContext, isCommandViewContextWithRef } from '../commands';
import { BuiltInCommands, GlyphChars } from '../constants';
import { ComparisionResultsNode } from '../views/explorerNodes';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
export interface DiffDirectoryCommandCommandArgs {
shaOrBranch1?: string;
shaOrBranch2?: string;
ref1?: string;
ref2?: string;
}
export class DiffDirectoryCommand extends ActiveEditorCommand {
@ -19,13 +19,29 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
constructor(
private readonly git: GitService
) {
super([Commands.DiffDirectory, Commands.ExternalDiffAll]);
super([Commands.DiffDirectory, Commands.ExternalDiffAll, Commands.ExplorersOpenDirectoryDiff, Commands.ExplorersOpenDirectoryDiffWithWorking]);
}
protected async preExecute(context: CommandContext, args: DiffDirectoryCommandCommandArgs = {}): Promise<any> {
if (context.command === Commands.ExternalDiffAll) {
args.shaOrBranch1 = 'HEAD';
args.shaOrBranch2 = undefined;
switch (context.command) {
case Commands.ExternalDiffAll:
args.ref1 = 'HEAD';
args.ref2 = undefined;
break;
case Commands.ExplorersOpenDirectoryDiff:
if (context.type === 'view' && context.node instanceof ComparisionResultsNode) {
args.ref1 = context.node.ref1;
args.ref2 = context.node.ref2;
}
break;
case Commands.ExplorersOpenDirectoryDiffWithWorking:
if (isCommandViewContextWithRef(context)) {
args.ref1 = context.node.ref;
args.ref2 = undefined;
}
break;
}
return this.execute(context.editor, context.uri, args);
@ -38,23 +54,20 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
const repoPath = await this.git.getRepoPath(uri);
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open directory compare`);
if (!args.shaOrBranch1) {
if (!args.ref1) {
args = { ...args };
const branches = await this.git.getBranches(repoPath);
const current = Iterables.find(branches, b => b.current);
if (current == null) return window.showWarningMessage(`Unable to open directory compare`);
const pick = await BranchesQuickPick.show(branches, `Compare ${current.name} to ${GlyphChars.Ellipsis}`);
const pick = await BranchesQuickPick.show(branches, `Compare Working Tree to ${GlyphChars.Ellipsis}`);
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
args.shaOrBranch1 = pick.branch.name;
if (args.shaOrBranch1 === undefined) return undefined;
args.ref1 = pick.branch.name;
if (args.ref1 === undefined) return undefined;
}
this.git.openDirectoryDiff(repoPath, args.shaOrBranch1, args.shaOrBranch2);
this.git.openDirectoryDiff(repoPath, args.ref1, args.ref2);
return undefined;
}
catch (ex) {

+ 3
- 3
src/gitService.ts 查看文件

@ -1332,15 +1332,15 @@ export class GitService extends Disposable {
return Git.difftool_fileDiff(repoPath, uri.fsPath, tool, staged);
}
async openDirectoryDiff(repoPath: string, sha1: string, sha2?: string, tool?: string) {
async openDirectoryDiff(repoPath: string, ref1: string, ref2?: string, tool?: string) {
if (!tool) {
tool = await this.getDiffTool(repoPath);
if (tool === undefined) throw new Error('No diff tool found');
}
Logger.log(`openDirectoryDiff('${repoPath}', '${sha1}', '${sha2}', '${tool}')`);
Logger.log(`openDirectoryDiff('${repoPath}', '${ref1}', '${ref2}', '${tool}')`);
return Git.difftool_dirDiff(repoPath, tool, sha1, sha2);
return Git.difftool_dirDiff(repoPath, tool, ref1, ref2);
}
async resolveReference(repoPath: string, ref: string, uri?: Uri) {

+ 5
- 5
src/quickPicks/commitDetails.ts 查看文件

@ -137,24 +137,24 @@ export class CommitDetailsQuickPick {
items.splice(index++, 0, new OpenCommitFileRevisionsCommandQuickPickItem(commit));
items.splice(index++, 0, new CommandQuickPickItem({
label: `$(git-compare) Compare Directory with Previous Revision`,
label: `$(git-compare) Open Directory Compare with Previous Revision`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.previousFileShortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(git-commit) ${commit.shortSha}`
}, Commands.DiffDirectory, [
commit.uri,
{
shaOrBranch1: commit.previousFileSha,
shaOrBranch2: commit.sha
ref1: commit.previousFileSha,
ref2: commit.sha
} as DiffDirectoryCommandCommandArgs
])
);
items.splice(index++, 0, new CommandQuickPickItem({
label: `$(git-compare) Compare Directory with Working Tree`,
label: `$(git-compare) Open Directory Compare with Working Tree`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha} ${GlyphChars.Space} $(git-compare) ${GlyphChars.Space} $(file-directory) Working Tree`
}, Commands.DiffDirectory, [
uri,
{
shaOrBranch1: commit.sha
ref1: commit.sha
} as DiffDirectoryCommandCommandArgs
])
);

+ 2
- 2
src/views/comparisionResultsNode.ts 查看文件

@ -11,8 +11,8 @@ export class ComparisionResultsNode extends ExplorerNode {
constructor(
repoPath: string,
private readonly ref1: string,
private readonly ref2: string,
public readonly ref1: string,
public readonly ref2: string,
private readonly explorer: Explorer
) {
super(GitUri.fromRepoPath(repoPath));

Loading…
取消
儲存