From 216eb6cad5d85405a6cc872ba870a596d0e6d3c6 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 5 Jan 2018 12:19:55 -0500 Subject: [PATCH] Renames Compare Selected Ancestor with Working --- CHANGELOG.md | 2 +- README.md | 6 +++--- package.json | 16 ++++++++-------- src/views/explorerCommands.ts | 34 +++++++++++++++++----------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5b5170..e70e7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds experimental support for providing blame annotations, code lens, etc on files with unsaved changes (enabled via `"gitlens.insiders": true`) -- closes [#112](https://github.com/eamodio/vscode-gitlens/issues/112) - Adds `gitlens.defaultDateStyle` setting to specify how dates will be displayed by default -- closes [#89](https://github.com/eamodio/vscode-gitlens/issues/89) - Adds *Compare with Working* command (`gitlens.explorers.compareWithWorking`) to branch, tag, and revision (commit) nodes in the **GitLens** view to compare the current selection with the current working tree in the **GitLens Results** view -- Adds *Compare Selected Base with Working* command (`gitlens.explorers.compareSelectedBaseWithWorking`) to branch nodes in the **GitLens** view once another branch within the same repository has been selected to compare the [merge base](https://git-scm.com/docs/git-merge-base) of current and previously selected branches with the working tree in the **GitLens Results** view -- closes [#240](https://github.com/eamodio/vscode-gitlens/issues/240) +- Adds *Compare Selected Ancestor with Working* command (`gitlens.explorers.compareSelectedAncestorWithWorking`) to branch nodes in the **GitLens** view once another branch within the same repository has been selected to compare the [merge base](https://git-scm.com/docs/git-merge-base) of current and previously selected branches with the working tree in the **GitLens Results** view -- closes [#240](https://github.com/eamodio/vscode-gitlens/issues/240) - Adds *Merge Branch (via Terminal)* command (`gitlens.explorers.terminalMergeBranch`) to branch nodes in the **GitLens** view - Adds *Rebase (Interactive) Branch (via Terminal)* command (`gitlens.explorers.terminalRebaseBranch`) to branch nodes in the **GitLens** view - Adds *Cherry Pick Commit (via Terminal)* command (`gitlens.explorers.terminalRebaseBranch`) to revision (commit) nodes in the **GitLens** & **GitLens Results** views diff --git a/README.md b/README.md index cc03066..45a67c2 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,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 Index (HEAD)*, *Compare with Working*, *Compare with Selected*, *Select for Compare*, *Cherry Pick Commit (via Terminal)*, *Revert Commit (via Terminal)*, *Rebase to Commit (via Terminal)*, *Reset to Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Create Tag (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 Index (HEAD)*, *Compare with Working*, *Compare with Remote*, *Compare with Selected*, *Compare Selected Base with Working*, *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Rebase (Interactive) Branch to Remote (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (via Terminal)...*, and *Refresh* commands + - Provides a context menu on each branch with *Open Branch in Remote*, *Compare with Index (HEAD)*, *Compare with Working*, *Compare with Remote*, *Compare with Selected*, *Compare Selected Ancestor with Working*, *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Rebase (Interactive) Branch to Remote (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (via Terminal)...*, and *Refresh* commands - Provides a context menu with *Open Branches in Remote*, and *Refresh* commands - **Remotes** node — provides a list of remotes @@ -179,7 +179,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 Index (HEAD)*, *Compare with Working*, *Compare with Selected*, *Select for Compare*, *Cherry Pick Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Create Tag (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*, *Show File History*, and *Show Commit File Details* commands - - Provides a context menu on each remote branch with *Open Branch in Remote*, *Compare with Index (HEAD)*, *Compare with Working*, *Compare with Selected*, *Compare Selected Base with Working*, *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (via Terminal)...*, and *Refresh* commands + - Provides a context menu on each remote branch with *Open Branch in Remote*, *Compare with Index (HEAD)*, *Compare with Working*, *Compare with Selected*, *Compare Selected Ancestor with Working*, *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (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 @@ -226,7 +226,7 @@ While GitLens is highly customizable and provides many [configuration settings]( - 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 - - Accessible via the following: *Compare with Index (HEAD)* command (`gitlens.explorers.compareWithHead`), *Compare with Remote* command (`gitlens.explorers.compareWithRemote`), *Compare with Working* command (`gitlens.explorers.compareWithWorking`), *Compare with Selected* command (`gitlens.explorers.compareWithSelected`), and *Compare Selected Base with Working* command (`gitlens.explorers.compareSelectedBaseWithWorking`) + - Accessible via the following: *Compare with Index (HEAD)* command (`gitlens.explorers.compareWithHead`), *Compare with Remote* command (`gitlens.explorers.compareWithRemote`), *Compare with Working* command (`gitlens.explorers.compareWithWorking`), *Compare with Selected* command (`gitlens.explorers.compareWithSelected`), and *Compare Selected Ancestor with Working* command (`gitlens.explorers.compareSelectedAncestorWithWorking`) - **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 Index (HEAD)*, *Compare with Working*, *Compare with Selected*, *Select for Compare*, *Cherry Pick Commit (via Terminal)*, *Revert Commit (via Terminal)*, *Rebase to Commit (via Terminal)*, *Reset to Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Create Tag (via Terminal)...*, and *Refresh* commands diff --git a/package.json b/package.json index 5ffc275..2f3591a 100644 --- a/package.json +++ b/package.json @@ -1451,8 +1451,8 @@ "category": "GitLens" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", - "title": "Compare Selected Base with Working", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", + "title": "Compare Selected Ancestor with Working", "category": "GitLens" }, { @@ -1884,7 +1884,7 @@ "when": "false" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "false" }, { @@ -2363,7 +2363,7 @@ "group": "7_gitlens_@1" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "viewItem == gitlens:branch && gitlens:explorers:canCompare == branch", "group": "7_gitlens_@2" }, @@ -2438,7 +2438,7 @@ "group": "7_gitlens_@1" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "viewItem == gitlens:branch:tracking && gitlens:explorers:canCompare == branch", "group": "7_gitlens_@2" }, @@ -2503,7 +2503,7 @@ "group": "7_gitlens_@1" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "viewItem == gitlens:current-branch && gitlens:explorers:canCompare == branch", "group": "7_gitlens_@2" }, @@ -2548,7 +2548,7 @@ "group": "7_gitlens_@1" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "viewItem == gitlens:current-branch:tracking && gitlens:explorers:canCompare == branch", "group": "7_gitlens_@2" }, @@ -2593,7 +2593,7 @@ "group": "7_gitlens_@1" }, { - "command": "gitlens.explorers.compareSelectedBaseWithWorking", + "command": "gitlens.explorers.compareSelectedAncestorWithWorking", "when": "viewItem == gitlens:remote-branch && gitlens:explorers:canCompare == branch", "group": "7_gitlens_@2" }, diff --git a/src/views/explorerCommands.ts b/src/views/explorerCommands.ts index 849f09a..daec5cc 100644 --- a/src/views/explorerCommands.ts +++ b/src/views/explorerCommands.ts @@ -38,7 +38,7 @@ 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.compareSelectedBaseWithWorking', this.compareSelectedBaseWithWorking, this); + commands.registerCommand('gitlens.explorers.compareSelectedAncestorWithWorking', this.compareSelectedAncestorWithWorking, 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); @@ -69,16 +69,6 @@ export class ExplorerCommands extends Disposable { return this.openFile(node); } - private async compareSelectedBaseWithWorking(node: BranchNode) { - if (this._selection === undefined || !(node instanceof BranchNode)) return; - if (this._selection.repoPath !== node.repoPath || this._selection.type !== 'branch') return; - - const base = await this.git.getMergeBase(this._selection.repoPath, this._selection.ref, node.ref); - if (base === undefined) return; - - ResultsExplorer.instance.showComparisonInResults(this._selection.repoPath, base, ''); - } - private compareWithHead(node: ExplorerNode) { if (!(node instanceof ExplorerRefNode)) return; @@ -91,6 +81,22 @@ export class ExplorerCommands extends Disposable { ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.branch.tracking, node.ref); } + private compareWithWorking(node: ExplorerNode) { + if (!(node instanceof ExplorerRefNode)) return; + + ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.ref, ''); + } + + private async compareSelectedAncestorWithWorking(node: BranchNode) { + if (this._selection === undefined || !(node instanceof BranchNode)) return; + if (this._selection.repoPath !== node.repoPath || this._selection.type !== 'branch') return; + + const commonAncestor = await this.git.getMergeBase(this._selection.repoPath, this._selection.ref, node.ref); + if (commonAncestor === undefined) return; + + ResultsExplorer.instance.showComparisonInResults(this._selection.repoPath, commonAncestor, ''); + } + private compareWithSelected(node: ExplorerNode) { if (this._selection === undefined || !(node instanceof ExplorerRefNode)) return; if (this._selection.repoPath !== node.repoPath) return; @@ -98,12 +104,6 @@ export class ExplorerCommands extends Disposable { ResultsExplorer.instance.showComparisonInResults(this._selection.repoPath, this._selection.ref, node.ref); } - private compareWithWorking(node: ExplorerNode) { - if (!(node instanceof ExplorerRefNode)) return; - - ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.ref, ''); - } - private _selection: ICompareSelected | undefined; private selectForCompare(node: ExplorerNode) {