Browse Source

Adds gitlens.explorers.compareWithHead command

Adds gitlens.explorers.compareWithRemote command
main
Eric Amodio 7 years ago
parent
commit
c2f7b3146d
5 changed files with 118 additions and 29 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +10
    -10
      README.md
  3. +91
    -18
      package.json
  4. +1
    -1
      src/views/comparisionResultsNode.ts
  5. +14
    -0
      src/views/explorerCommands.ts

+ 2
- 0
CHANGELOG.md View File

@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added
- Adds semi-persistent results for commit operations, via the `Show Commit Details` command (`gitlens.showQuickCommitDetails`) in the `GitLens Results` view -- closes [#237](https://github.com/eamodio/vscode-gitlens/issues/237)
- Adds `Show in Results` option to the commit details quick pick menu to show the commit in the `GitLens Results` view
- Adds `Compare with Index (HEAD)` command (`gitlens.explorers.compareWithHead`) to branch, remote branch, tag, and revision (commit) nodes in the `GitLens` view to compare the current selection with the current index (HEAD) in the `GitLens Results` view
- Adds `Compare with Remote` command (`gitlens.explorers.compareWithRemote`) to branch nodes in the `GitLens` view to compare the current selection with its remote tracking branch in the `GitLens Results` view
### Changed
- Improves startup performance and reduces package size

+ 10
- 10
README.md View File

@ -158,9 +158,9 @@ While GitLens is highly customizable and provides many [configuration settings](
- `Red` - behind the upstream
- `Yellow` - both ahead of and behind the upstream
- 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 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 Index (HEAD)`, `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`, `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 on each branch with `Open Branch in Remote`, `Compare with Index (HEAD)`, `Compare with 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
@ -168,24 +168,24 @@ While GitLens is highly customizable and provides many [configuration settings](
- Expand each remote to see its list of branches
- Expand each branch 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`, and `Refresh` commands
- 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 Index (HEAD)`, `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`, `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 branch with `Open Branch in Remote`, `Compare with Index (HEAD)`, `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
- `Stashes` node — provides a list of stashed changes
- Expand each stash to quickly see the set of files stashed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit Message to Clipboard`, `Compare with Selected`, `Select for Compare`, and `Refresh` commands
- Provides a context menu on each stash with `Apply Stashed Changes` (confirmation required), `Delete Stashed Changes` (confirmation required), `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit Message to Clipboard`, `Compare with Index (HEAD)`, `Compare with Selected`, `Select for Compare`, and `Refresh` commands
- Provides a context menu on each stashed file with `Apply Changes`, `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, and `Show File History` commands
- Provides a context menu with `Stash Changes`, and `Refresh` commands
- `Tags` node — 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 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 Index (HEAD)`, `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`, `Open Directory Compare with Working Tree`, and `Refresh` commands
- Provides a context menu on each tag with `Compare with Index (HEAD)`, `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
@ -212,13 +212,13 @@ While GitLens is highly customizable and provides many [configuration settings](
- Provides semi-persistent results for commit search operations, via the `Show Commit Search` command (`gitlens.showCommitSearch`), file history operations, via the `Show File History` command (`gitlens.showQuickFileHistory`), and commit operations, via the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
- 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 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 Index (HEAD)`, `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 semi-persistent results for revision comparison operations, via the `Select for Compare` command (`gitlens.explorers.selectForCompare`) and the `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- Provides semi-persistent results for revision comparison operations, via the `Compare with Index (HEAD)` command (`gitlens.explorers.compareWithHead`), `Compare with Remote` command (`gitlens.explorers.compareWithRemote`), `Select for Compare` command (`gitlens.explorers.selectForCompare`), and the `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- `Commits` node — provides a list of the commits between the compared revisions (branches or commits)
- 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 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 Index (HEAD)`, `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
- `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

+ 91
- 18
package.json View File

@ -1436,6 +1436,16 @@
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareWithHead",
"title": "Compare with Index (HEAD)",
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareWithRemote",
"title": "Compare with Remote",
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareWithSelected",
"title": "Compare with Selected",
"category": "GitLens"
@ -1815,6 +1825,14 @@
"when": "false"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "false"
},
{
"command": "gitlens.explorers.compareWithRemote",
"when": "false"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "false"
},
@ -2239,14 +2257,19 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:branch",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:branch && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:branch",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2279,14 +2302,24 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithRemote",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:branch:tracking && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@2"
"group": "7_gitlens@4"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2314,14 +2347,19 @@
"group": "8_gitlens@4"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:current-branch",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:current-branch && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:current-branch",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.terminalCreateBranch",
@ -2334,14 +2372,24 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithRemote",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:current-branch:tracking && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@2"
"group": "7_gitlens@4"
},
{
"command": "gitlens.explorers.terminalCreateBranch",
@ -2359,14 +2407,19 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:remote-branch",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:remote-branch && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:remote-branch",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2434,14 +2487,19 @@
"group": "5_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:commit",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:commit && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:commit",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.openCommitInRemote",
@ -2484,14 +2542,19 @@
"group": "5_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:commit:current",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:commit:current && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:commit:current",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.terminalRebaseCommit",
@ -2634,14 +2697,19 @@
"group": "4_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:stash",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:stash && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:stash",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.applyChanges",
@ -2734,14 +2802,19 @@
"group": "8_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:tag",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:tag && gitlens:explorers:canCompare",
"group": "7_gitlens@1"
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:tag",
"group": "7_gitlens@2"
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",

+ 1
- 1
src/views/comparisionResultsNode.ts View File

@ -49,7 +49,7 @@ export class ComparisionResultsNode extends ExplorerNode {
async getTreeItem(): Promise<TreeItem> {
const repo = await this.explorer.git.getRepository(this.uri.repoPath!);
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1)} to ${GitService.shortenSha(this.ref2)} ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`, TreeItemCollapsibleState.Expanded);
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1)} to ${GitService.shortenSha(this.ref2 || 'HEAD')} ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.ComparisonResults;
return item;
}

+ 14
- 0
src/views/explorerCommands.ts View File

@ -32,6 +32,8 @@ export class ExplorerCommands extends Disposable {
commands.registerCommand('gitlens.explorers.openChangedFileChangesWithWorking', this.openChangedFileChangesWithWorking, this);
commands.registerCommand('gitlens.explorers.openChangedFileRevisions', this.openChangedFileRevisions, this);
commands.registerCommand('gitlens.explorers.applyChanges', this.applyChanges, this);
commands.registerCommand('gitlens.explorers.compareWithHead', this.compareWithHead, this);
commands.registerCommand('gitlens.explorers.compareWithRemote', this.compareWithRemote, this);
commands.registerCommand('gitlens.explorers.compareWithSelected', this.compareWithSelected, this);
commands.registerCommand('gitlens.explorers.selectForCompare', this.selectForCompare, this);
commands.registerCommand('gitlens.explorers.terminalCheckoutBranch', this.terminalCheckoutBranch, this);
@ -53,6 +55,18 @@ export class ExplorerCommands extends Disposable {
return this.openFile(node);
}
private async compareWithHead(node: ExplorerNode) {
if (!(node instanceof ExplorerRefNode)) return;
ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.ref, 'HEAD');
}
private async compareWithRemote(node: BranchNode) {
if (!node.branch.tracking) return;
ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.branch.tracking, node.ref);
}
private async compareWithSelected(node: ExplorerNode) {
if (this._selection === undefined || !(node instanceof ExplorerRefNode)) return;
if (this._selection.repoPath !== node.repoPath) return;

Loading…
Cancel
Save