瀏覽代碼

Adds compare node to branches view

main
Eric Amodio 4 年之前
父節點
當前提交
e2ecc348fd
共有 9 個文件被更改,包括 134 次插入28 次删除
  1. +64
    -10
      package.json
  2. +1
    -0
      src/config.ts
  3. +26
    -1
      src/views/branchesView.ts
  4. +10
    -9
      src/views/nodes/branchNode.ts
  5. +4
    -1
      src/views/nodes/branchesNode.ts
  6. +6
    -5
      src/views/nodes/compareBranchNode.ts
  7. +15
    -0
      src/webviews/apps/settings/partials/views.branches.html
  8. +4
    -1
      src/webviews/apps/settings/partials/views.commits.html
  9. +4
    -1
      src/webviews/apps/settings/partials/views.repositories.html

+ 64
- 10
package.json 查看文件

@ -1576,6 +1576,27 @@
"markdownDescription": "Specifies whether to show pull requests (if any) associated with commits in the _Branches_ view. Requires a connection to a supported remote service (e.g. GitHub)",
"scope": "window"
},
"gitlens.views.branches.showBranchComparison": {
"anyOf": [
{
"enum": [
false
]
},
{
"type": "string",
"enum": [
"branch"
],
"enumDescriptions": [
"Compares the branch with a user-selected reference"
]
}
],
"default": "branch",
"markdownDescription": "Specifies whether to show a comparison of the branch with a user-selected reference (branch, tag. etc) in the _Branches_ view",
"scope": "window"
},
"gitlens.views.commitFileFormat": {
"type": "string",
"default": "${file}",
@ -1666,13 +1687,13 @@
"working"
],
"enumDescriptions": [
"Compares the current branch to the user-selected reference",
"Compares the working tree to the user-selected reference"
"Compares the current branch with a user-selected reference",
"Compares the working tree with a user-selected reference"
]
}
],
"default": "working",
"markdownDescription": "Specifies whether to show a comparison of a user-selected reference (branch, tag. etc) to the current branch or the working tree in the _Commits_ view",
"markdownDescription": "Specifies whether to show a comparison of the current branch or the working tree with a user-selected reference (branch, tag. etc) in the _Commits_ view",
"scope": "window"
},
"gitlens.views.compare.avatars": {
@ -1973,13 +1994,13 @@
"working"
],
"enumDescriptions": [
"Compares the current branch to the user-selected reference",
"Compares the working tree to the user-selected reference"
"Compares the current branch with a user-selected reference",
"Compares the working tree with a user-selected reference"
]
}
],
"default": "working",
"markdownDescription": "Specifies whether to show a comparison of a user-selected reference (branch, tag. etc) to the current branch or the working tree in the _Repositories_ view",
"markdownDescription": "Specifies whether to show a comparison of the current branch or the working tree with a user-selected reference (branch, tag. etc) in the _Repositories_ view",
"scope": "window"
},
"gitlens.views.search.avatars": {
@ -3688,6 +3709,16 @@
"category": "GitLens"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOn",
"title": "Show Branch Comparison",
"category": "GitLens"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOff",
"title": "Hide Branch Comparison",
"category": "GitLens"
},
{
"command": "gitlens.views.commits.copy",
"title": "Copy",
"category": "GitLens"
@ -5021,6 +5052,14 @@
"when": "false"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOn",
"when": "false"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOff",
"when": "false"
},
{
"command": "gitlens.views.commits.copy",
"when": "false"
},
@ -5880,6 +5919,16 @@
"group": "1_gitlens@0"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOn",
"when": "view =~ /^gitlens\\.views\\.branches/ && !config.gitlens.views.branches.showBranchComparison",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOff",
"when": "view =~ /^gitlens\\.views\\.branches/ && config.gitlens.views.branches.showBranchComparison",
"group": "1_gitlens@1"
},
{
"command": "gitlens.views.switchToAnotherBranch",
"when": "!gitlens:readonly && view =~ /^gitlens\\.views\\.commits/",
"group": "navigation@10"
@ -7130,12 +7179,12 @@
},
{
"command": "gitlens.views.setBranchComparisonToWorking",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+branch\\b)/",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+branch\\b)/",
"group": "inline@2"
},
{
"command": "gitlens.views.setBranchComparisonToBranch",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+working\\b)/",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+working\\b)/",
"group": "inline@2"
},
{
@ -7150,15 +7199,20 @@
},
{
"command": "gitlens.views.setBranchComparisonToWorking",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+branch\\b)/",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+branch\\b)/",
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.setBranchComparisonToBranch",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+working\\b)/",
"when": "viewItem =~ /gitlens:compare:branch\\b(?=.*?\\b\\+comparing\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+working\\b)/",
"group": "1_gitlens@2"
},
{
"command": "gitlens.views.branches.setShowBranchComparisonOff",
"when": "view =~ /gitlens\\.views\\.branches\\b/ && viewItem =~ /gitlens:compare:branch\\b/",
"group": "8_gitlens@1"
},
{
"command": "gitlens.views.commits.setShowBranchComparisonOff",
"when": "view =~ /gitlens\\.views\\.commits\\b/ && viewItem =~ /gitlens:compare:branch\\b/",
"group": "8_gitlens@1"

+ 1
- 0
src/config.ts 查看文件

@ -465,6 +465,7 @@ export interface BranchesViewConfig {
showForBranches: boolean;
showForCommits: boolean;
};
showBranchComparison: false | ViewShowBranchComparison;
}
export interface CommitsViewConfig {

+ 26
- 1
src/views/branchesView.ts 查看文件

@ -8,7 +8,13 @@ import {
TreeItemCollapsibleState,
window,
} from 'vscode';
import { BranchesViewConfig, configuration, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import {
BranchesViewConfig,
configuration,
ViewBranchesLayout,
ViewFilesLayout,
ViewShowBranchComparison,
} from '../configuration';
import { Container } from '../container';
import {
GitBranchReference,
@ -223,6 +229,16 @@ export class BranchesView extends ViewBase
);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this);
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOn'),
() => this.setShowBranchComparison(true),
this,
);
commands.registerCommand(
this.getQualifiedCommand('setShowBranchComparisonOff'),
() => this.setShowBranchComparison(false),
this,
);
}
protected filterConfigurationChanged(e: ConfigurationChangeEvent) {
@ -353,4 +369,13 @@ export class BranchesView extends ViewBase
private setShowAvatars(enabled: boolean) {
return configuration.updateEffective('views', this.configKey, 'avatars', enabled);
}
private setShowBranchComparison(enabled: boolean) {
return configuration.updateEffective(
'views',
this.configKey,
'showBranchComparison',
enabled ? ViewShowBranchComparison.Working : false,
);
}
}

+ 10
- 9
src/views/nodes/branchNode.ts 查看文件

@ -131,15 +131,18 @@ export class BranchNode
]);
if (log == null) return [new MessageNode(this.view, this, 'No commits could be found.')];
if (this.options.showTracking) {
if (this.options.showComparison !== false && this.view instanceof CommitsView) {
children.push(new CompareBranchNode(this.uri, this.view, this, this.branch));
}
if (
this.options.showComparison !== false &&
(this.view instanceof BranchesView || this.view instanceof CommitsView)
) {
children.push(new CompareBranchNode(this.uri, this.view, this, this.branch));
}
if (pr != null) {
children.push(new PullRequestNode(this.view, this, pr, this.branch));
}
if (pr != null) {
children.push(new PullRequestNode(this.view, this, pr, this.branch));
}
if (this.options.showTracking) {
const status = {
ref: this.branch.ref,
repoPath: this.branch.repoPath,
@ -170,8 +173,6 @@ export class BranchNode
new BranchTrackingStatusNode(this.view, this, this.branch, status, 'none', this.root),
);
}
} else if (pr != null) {
children.push(new PullRequestNode(this.view, this, pr, this.branch));
}
if (children.length !== 0) {

+ 4
- 1
src/views/nodes/branchesNode.ts 查看文件

@ -44,7 +44,10 @@ export class BranchesNode extends ViewNode {
if (branches.length === 0) return [new MessageNode(this.view, this, 'No branches could be found.')];
const branchNodes = branches.map(
b => new BranchNode(GitUri.fromRepoPath(this.uri.repoPath!, b.ref), this.view, this, b, false),
b =>
new BranchNode(GitUri.fromRepoPath(this.uri.repoPath!, b.ref), this.view, this, b, false, {
showComparison: this.view.config.showBranchComparison,
}),
);
if (this.view.config.branches.layout === ViewBranchesLayout.List) return branchNodes;

+ 6
- 5
src/views/nodes/compareBranchNode.ts 查看文件

@ -1,5 +1,6 @@
'use strict';
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { BranchesView } from '../branchesView';
import { CommitsView } from '../commitsView';
import { BranchComparison, BranchComparisons, GlyphChars, WorkspaceState } from '../../constants';
import { BranchSorting, TagSorting, ViewShowBranchComparison } from '../../configuration';
@ -14,7 +15,7 @@ import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { debug, gate, log, Strings } from '../../system';
import { ContextValues, ViewNode } from './viewNode';
export class CompareBranchNode extends ViewNode<CommitsView | RepositoriesView> {
export class CompareBranchNode extends ViewNode<BranchesView | CommitsView | RepositoriesView> {
static key = ':compare-branch';
static getId(repoPath: string, name: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`;
@ -25,7 +26,7 @@ export class CompareBranchNode extends ViewNode
constructor(
uri: GitUri,
view: CommitsView | RepositoriesView,
view: BranchesView | CommitsView | RepositoriesView,
parent: ViewNode,
public readonly branch: GitBranch,
) {
@ -108,9 +109,9 @@ export class CompareBranchNode extends ViewNode
command: 'gitlens.views.executeNodeCallback',
arguments: [() => this.compareWith()],
};
item.contextValue = `${ContextValues.CompareBranch}${this._compareWith === undefined ? '' : '+comparing'}+${
this.comparisonNotation === '..' ? 'twodot' : 'threedot'
}+${this.comparisonType}`;
item.contextValue = `${ContextValues.CompareBranch}${this.branch.current ? '+current' : ''}${
this._compareWith === undefined ? '' : '+comparing'
}+${this.comparisonNotation === '..' ? 'twodot' : 'threedot'}+${this.comparisonType}`;
item.description = description;
if (this.compareWithWorkingTree) {
item.iconPath = {

+ 15
- 0
src/webviews/apps/settings/partials/views.branches.html 查看文件

@ -20,6 +20,21 @@
<div class="settings settings--fixed ml-1">
<div class="setting">
<div class="setting__input">
<input
id="views.branches.showBranchComparison"
name="views.branches.showBranchComparison"
type="checkbox"
value="branch"
data-setting
/>
<label for="views.branches.showBranchComparison"
>Show a comparison of the branch with a user-selected reference (branch, tag, etc)
</label>
</div>
</div>
<div class="setting">
<div class="setting__input">
<label for="views.branches.branches.layout">Layout branches</label>
<div class="select-container">
<select

+ 4
- 1
src/webviews/apps/settings/partials/views.commits.html 查看文件

@ -28,7 +28,7 @@
data-setting
/>
<label for="views.commits.showBranchComparison"
>Show a comparison of a user-selected reference (branch, tag, etc) to the
>Show a comparison of the
<div class="select-container">
<select
id="views.commits.showBranchComparison"
@ -41,6 +41,9 @@
</select>
</div>
</label>
<label for="views.commits.showBranchComparison"
>with a user-selected reference (branch, tag, etc)
</label>
</div>
</div>

+ 4
- 1
src/webviews/apps/settings/partials/views.repositories.html 查看文件

@ -32,7 +32,7 @@
disabled
/>
<label for="views.repositories.showBranchComparison"
>Show a comparison of a user-selected reference (branch, tag, etc) to the
>Show a comparison of the
<div class="select-container">
<select
id="views.repositories.showBranchComparison"
@ -46,6 +46,9 @@
</select>
</div>
</label>
<label for="views.repositories.showBranchComparison"
>with a user-selected reference (branch, tag, etc)
</label>
</div>
</div>

Loading…
取消
儲存