Przeglądaj źródła

Closes #240 - adds Compare Selected Base with Working command

Adds Compare with Working command
main
Eric Amodio 7 lat temu
rodzic
commit
54941e6068
5 zmienionych plików z 161 dodań i 43 usunięć
  1. +3
    -1
      CHANGELOG.md
  2. +13
    -11
      README.md
  3. +110
    -22
      package.json
  4. +2
    -2
      src/views/comparisionResultsNode.ts
  5. +33
    -7
      src/views/explorerCommands.ts

+ 3
- 1
CHANGELOG.md Wyświetl plik

@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added
- 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)
### Fixed
- Fixes issue where the `GitLens Results` view wouldn't properly update when replacing existing results
@ -22,7 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds `Toggle File Heatmap Annotations` command (`gitlens.toggleFileHeatmap`) to toggle the heatmap annotations on and off
- 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 Index (HEAD)` command (`gitlens.explorers.compareWithHead`) to 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

+ 13
- 11
README.md Wyświetl plik

@ -167,9 +167,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 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 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`, `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 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 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)`, `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
@ -177,24 +177,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 Index (HEAD)`, `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 Working`, `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 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 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)`, `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 Index (HEAD)`, `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 Working`, `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 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 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`, `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 Index (HEAD)`, `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 Working`, `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
@ -219,15 +219,17 @@ While GitLens is highly customizable and provides many [configuration settings](
- Adds an on-demand, [customizable](#gitlens-results-view-settings) `GitLens Results` view to the Explorer activity
- 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`)
- Provides semi-persistent results for commit search, file history, and commit operations
- Accessible via the following: `Show Commit Search` command (`gitlens.showCommitSearch`), `Show File History` command (`gitlens.showQuickFileHistory`), and `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 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 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`, `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 `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`)
- 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`)
- `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 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 Working`, `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

+ 110
- 22
package.json Wyświetl plik

@ -1451,6 +1451,11 @@
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"title": "Compare Selected Base with Working",
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareWithHead",
"title": "Compare with Index (HEAD)",
"category": "GitLens"
@ -1466,6 +1471,11 @@
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareWithWorking",
"title": "Compare with Working",
"category": "GitLens"
},
{
"command": "gitlens.explorers.selectForCompare",
"title": "Select for Compare",
"category": "GitLens"
@ -1844,6 +1854,10 @@
"when": "false"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "false"
},
{
"command": "gitlens.explorers.compareWithHead",
"when": "false"
},
@ -1856,6 +1870,10 @@
"when": "false"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "false"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "false"
},
@ -2281,14 +2299,24 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:branch",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:branch && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "viewItem == gitlens:branch && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:branch",
"group": "7_gitlens@3"
"group": "7_gitlens_@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2321,24 +2349,34 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"command": "gitlens.explorers.compareWithRemote",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithRemote",
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:branch:tracking && gitlens:explorers:canCompare",
"group": "7_gitlens@3"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "viewItem == gitlens:branch:tracking && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:branch:tracking",
"group": "7_gitlens@4"
"group": "7_gitlens_@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2371,14 +2409,24 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:current-branch",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:current-branch && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "viewItem == gitlens:current-branch && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:current-branch",
"group": "7_gitlens@3"
"group": "7_gitlens_@3"
},
{
"command": "gitlens.explorers.terminalCreateBranch",
@ -2391,24 +2439,34 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithHead",
"command": "gitlens.explorers.compareWithRemote",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithRemote",
"command": "gitlens.explorers.compareWithHead",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:current-branch:tracking && gitlens:explorers:canCompare",
"group": "7_gitlens@3"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "viewItem == gitlens:current-branch:tracking && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:current-branch:tracking",
"group": "7_gitlens@4"
"group": "7_gitlens_@3"
},
{
"command": "gitlens.explorers.terminalCreateBranch",
@ -2431,14 +2489,24 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:remote-branch",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:remote-branch && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedBaseWithWorking",
"when": "viewItem == gitlens:remote-branch && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:remote-branch",
"group": "7_gitlens@3"
"group": "7_gitlens_@3"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",
@ -2511,14 +2579,19 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:commit",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:commit && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:commit",
"group": "7_gitlens@3"
"group": "7_gitlens_@2"
},
{
"command": "gitlens.openCommitInRemote",
@ -2566,14 +2639,19 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:commit:current",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:commit:current && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:commit:current",
"group": "7_gitlens@3"
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.terminalRebaseCommit",
@ -2721,14 +2799,19 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:stash",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:stash && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:stash",
"group": "7_gitlens@3"
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.applyChanges",
@ -2826,14 +2909,19 @@
"group": "7_gitlens@1"
},
{
"command": "gitlens.explorers.compareWithWorking",
"when": "viewItem == gitlens:tag",
"group": "7_gitlens@2"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem == gitlens:tag && gitlens:explorers:canCompare",
"group": "7_gitlens@2"
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem == gitlens:tag",
"group": "7_gitlens@3"
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",

+ 2
- 2
src/views/comparisionResultsNode.ts Wyświetl plik

@ -21,7 +21,7 @@ export class ComparisionResultsNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> {
this.resetChildren();
const commitsQueryFn = (maxCount: number | undefined) => this.explorer.git.getLogForRepo(this.uri.repoPath!, { maxCount: maxCount, ref: `${this.ref1}...${this.ref2}` });
const commitsQueryFn = (maxCount: number | undefined) => this.explorer.git.getLogForRepo(this.uri.repoPath!, { maxCount: maxCount, ref: `${this.ref1}...${this.ref2 || 'HEAD'}` });
const commitsLabelFn = (log: GitLog | undefined) => {
const count = log !== undefined ? log.count : 0;
const truncated = log !== undefined ? log.truncated : false;
@ -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 || 'HEAD')} ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`, TreeItemCollapsibleState.Expanded);
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1)} to ${this.ref2 !== '' ? GitService.shortenSha(this.ref2) : 'Working Tree'} ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.ComparisonResults;
return item;
}

+ 33
- 7
src/views/explorerCommands.ts Wyświetl plik

@ -11,6 +11,12 @@ export interface RefreshNodeCommandArgs {
maxCount?: number;
}
interface ICompareSelected {
ref: string;
repoPath: string | undefined;
type: 'branch' | 'ref';
}
export class ExplorerCommands extends Disposable {
private _disposable: Disposable | undefined;
@ -32,9 +38,11 @@ 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.compareWithHead', this.compareWithHead, this);
commands.registerCommand('gitlens.explorers.compareWithRemote', this.compareWithRemote, this);
commands.registerCommand('gitlens.explorers.compareWithSelected', this.compareWithSelected, this);
commands.registerCommand('gitlens.explorers.compareWithWorking', this.compareWithWorking, this);
commands.registerCommand('gitlens.explorers.selectForCompare', this.selectForCompare, this);
commands.registerCommand('gitlens.explorers.terminalCheckoutBranch', this.terminalCheckoutBranch, this);
commands.registerCommand('gitlens.explorers.terminalCreateBranch', this.terminalCreateBranch, this);
@ -55,36 +63,54 @@ export class ExplorerCommands extends Disposable {
return this.openFile(node);
}
private async compareWithHead(node: ExplorerNode) {
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;
ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.ref, 'HEAD');
}
private async compareWithRemote(node: BranchNode) {
private compareWithRemote(node: BranchNode) {
if (!node.branch.tracking) return;
ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.branch.tracking, node.ref);
}
private async compareWithSelected(node: ExplorerNode) {
private compareWithSelected(node: ExplorerNode) {
if (this._selection === undefined || !(node instanceof ExplorerRefNode)) return;
if (this._selection.repoPath !== node.repoPath) return;
ResultsExplorer.instance.showComparisonInResults(this._selection.repoPath, this._selection.ref, node.ref);
}
private _selection: { ref: string, repoPath: string | undefined } | undefined;
private compareWithWorking(node: ExplorerNode) {
if (!(node instanceof ExplorerRefNode)) return;
ResultsExplorer.instance.showComparisonInResults(node.repoPath, node.ref, '');
}
private _selection: ICompareSelected | undefined;
private async selectForCompare(node: ExplorerNode) {
private selectForCompare(node: ExplorerNode) {
if (!(node instanceof ExplorerRefNode)) return;
const type = node instanceof BranchNode ? 'branch' : 'ref';
this._selection = {
ref: node.ref,
repoPath: node.repoPath
repoPath: node.repoPath,
type: type
};
setCommandContext(CommandContext.ExplorersCanCompare, true);
setCommandContext(CommandContext.ExplorersCanCompare, type);
}
private openChanges(node: CommitNode | StashNode) {

Ładowanie…
Anuluj
Zapisz