Skip to content

Commit 49c7deb

Browse files
committed
Changes node labels to takes advantage of new node descriptions
1 parent d1bb0ae commit 49c7deb

21 files changed

+214
-91
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1313
- Adds the _Search Commits_ command to the search results inline toolbar
1414
- Reopens the commit search when clicking on a search results without results
1515
- Adds a _Collapse_ command to the toolbars of the _Compare_ and _Search Commits_ views
16+
- Adds a `gitlens.views.commitFileDescriptionFormat` setting to specify the description format of a committed file in the views
17+
- Adds a `gitlens.views.commitDescriptionFormat` setting to specify the description format of committed changes in the views
18+
- Adds a `gitlens.views.stashFileDescriptionFormat` setting to specify the description format of a stashed file in the views
19+
- Adds a `gitlens.views.stashDescriptionFormat` setting to specify the description format of stashed changes in the views
20+
- Adds a `gitlens.views.statusFileDescriptionFormat` setting to specify the description format of the status of a working or committed file in the views
1621

1722
### Fixed
1823

README.md

Lines changed: 14 additions & 9 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "https://github.com/eamodio/vscode-gitlens.git"
1919
},
2020
"engines": {
21-
"vscode": "^1.29.0"
21+
"vscode": "^1.30.0"
2222
},
2323
"main": "./dist/extension",
2424
"icon": "images/gitlens-icon.png",
@@ -1207,16 +1207,28 @@
12071207
},
12081208
"gitlens.views.commitFileFormat": {
12091209
"type": "string",
1210-
"default": "${filePath}",
1210+
"default": "${file}",
12111211
"markdownDescription": "Specifies the format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
12121212
"scope": "window"
12131213
},
1214+
"gitlens.views.commitFileDescriptionFormat": {
1215+
"type": "string",
1216+
"default": "${directory}",
1217+
"markdownDescription": "Specifies the description format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
1218+
"scope": "window"
1219+
},
12141220
"gitlens.views.commitFormat": {
12151221
"type": "string",
1216-
"default": "${message} • ${authorAgoOrDate}${ • changes}${ (id)}",
1222+
"default": "${message}",
12171223
"markdownDescription": "Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
12181224
"scope": "window"
12191225
},
1226+
"gitlens.views.commitDescriptionFormat": {
1227+
"type": "string",
1228+
"default": "${changes • }${authorAgoOrDate}",
1229+
"markdownDescription": "Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1230+
"scope": "window"
1231+
},
12201232
"gitlens.views.compare.enabled": {
12211233
"type": "boolean",
12221234
"default": true,
@@ -1469,22 +1481,40 @@
14691481
},
14701482
"gitlens.views.stashFileFormat": {
14711483
"type": "string",
1472-
"default": "${filePath}",
1484+
"default": "${file}",
14731485
"markdownDescription": "Specifies the format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
14741486
"scope": "window"
14751487
},
1488+
"gitlens.views.stashFileDescriptionFormat": {
1489+
"type": "string",
1490+
"default": "${directory}",
1491+
"markdownDescription": "Specifies the description format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
1492+
"scope": "window"
1493+
},
14761494
"gitlens.views.stashFormat": {
14771495
"type": "string",
1478-
"default": "${message} • ${agoOrDate}${ • changes}",
1496+
"default": "${message}",
14791497
"markdownDescription": "Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
14801498
"scope": "window"
14811499
},
1500+
"gitlens.views.stashDescriptionFormat": {
1501+
"type": "string",
1502+
"default": "${changes • }${agoOrDate}",
1503+
"markdownDescription": "Specifies the description format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1504+
"scope": "window"
1505+
},
14821506
"gitlens.views.statusFileFormat": {
14831507
"type": "string",
1484-
"default": "${working }${filePath}",
1508+
"default": "${working }${file}",
14851509
"markdownDescription": "Specifies the format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
14861510
"scope": "window"
14871511
},
1512+
"gitlens.views.statusFileDescriptionFormat": {
1513+
"type": "string",
1514+
"default": "${directory}",
1515+
"markdownDescription": "Specifies the description format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
1516+
"scope": "window"
1517+
},
14881518
"gitlens.advanced.blame.customArguments": {
14891519
"type": "array",
14901520
"default": null,

src/ui/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export interface RepositoriesViewConfig {
339339
branches: {
340340
layout: ViewBranchesLayout;
341341
};
342+
compact: boolean;
342343
enabled: boolean;
343344
files: ViewsFilesConfig;
344345
includeWorkingTree: boolean;
@@ -360,16 +361,21 @@ export interface ViewsConfig {
360361
compact: boolean;
361362
threshold: number;
362363
};
364+
commitFileDescriptionFormat: string;
363365
commitFileFormat: string;
366+
commitDescriptionFormat: string;
364367
commitFormat: string;
365368
compare: CompareViewConfig;
366369
// dateFormat: string | null;
367370
defaultItemLimit: number;
368371
lineHistory: LineHistoryViewConfig;
369372
repositories: RepositoriesViewConfig;
370373
search: SearchViewConfig;
374+
stashFileDescriptionFormat: string;
371375
stashFileFormat: string;
376+
stashDescriptionFormat: string;
372377
stashFormat: string;
378+
statusFileDescriptionFormat: string;
373379
statusFileFormat: string;
374380
}
375381

src/views/nodes/branchNode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
9797
}
9898

9999
async getTreeItem(): Promise<TreeItem> {
100-
let name = this.label;
100+
const name = this.label;
101101
let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`;
102102
let iconSuffix = '';
103103

104+
let description;
104105
if (!this.branch.remote && this.branch.tracking !== undefined) {
105106
if (this.view.config.showTrackingBranch) {
106-
name += `${this.branch.getTrackingStatus({ prefix: `${GlyphChars.Space} ` })}${GlyphChars.Space} ${
107+
description = `${this.branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${
107108
GlyphChars.ArrowLeftRightLong
108109
}${GlyphChars.Space} ${this.branch.tracking}`;
109110
}
@@ -128,6 +129,7 @@ export class BranchNode extends ViewRefNode<RepositoriesView> implements Pageabl
128129
`${!this._root && this.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`,
129130
TreeItemCollapsibleState.Collapsed
130131
);
132+
item.description = description;
131133
item.id = this.id;
132134
item.tooltip = tooltip;
133135

src/views/nodes/commitFileNode.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class CommitFileNode extends ViewRefNode {
7171

7272
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
7373
item.contextValue = this.resourceType;
74+
item.description = this.description;
7475
item.tooltip = this.tooltip;
7576

7677
if ((this._displayAs & CommitFileNodeDisplayAs.CommitIcon) === CommitFileNodeDisplayAs.CommitIcon) {
@@ -92,13 +93,30 @@ export class CommitFileNode extends ViewRefNode {
9293

9394
item.command = this.getCommand();
9495

95-
// Only cache the label/tooltip for a single refresh
96+
// Only cache the label/description/tooltip for a single refresh
9697
this._label = undefined;
98+
this._description = undefined;
9799
this._tooltip = undefined;
98100

99101
return item;
100102
}
101103

104+
private _description: string | undefined;
105+
get description() {
106+
if (this._description === undefined) {
107+
this._description =
108+
this._displayAs & CommitFileNodeDisplayAs.CommitLabel
109+
? CommitFormatter.fromTemplate(this.getCommitDescriptionTemplate(), this.commit, {
110+
truncateMessageAtNewLine: true,
111+
dateFormat: Container.config.defaultDateFormat
112+
} as ICommitFormatOptions)
113+
: StatusFileFormatter.fromTemplate(this.getCommitFileDescriptionTemplate(), this.file, {
114+
relativePath: this.relativePath
115+
} as IStatusFormatOptions);
116+
}
117+
return this._description;
118+
}
119+
102120
private _folderName: string | undefined;
103121
get folderName() {
104122
if (this._folderName === undefined) {
@@ -165,10 +183,18 @@ export class CommitFileNode extends ViewRefNode {
165183
return this.view.config.commitFormat;
166184
}
167185

186+
protected getCommitDescriptionTemplate() {
187+
return this.view.config.commitDescriptionFormat;
188+
}
189+
168190
protected getCommitFileTemplate() {
169191
return this.view.config.commitFileFormat;
170192
}
171193

194+
protected getCommitFileDescriptionTemplate() {
195+
return this.view.config.commitFileDescriptionFormat;
196+
}
197+
172198
getCommand(): Command | undefined {
173199
return {
174200
title: 'Compare File with Previous Revision',

src/views/nodes/commitNode.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ export class CommitNode extends ViewRefNode {
6969
}
7070

7171
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
72-
7372
item.contextValue =
7473
this.branch === undefined || this.branch.current ? ResourceType.CommitOnCurrentBranch : ResourceType.Commit;
74+
item.description = CommitFormatter.fromTemplate(this.view.config.commitDescriptionFormat, this.commit, {
75+
truncateMessageAtNewLine: true,
76+
dateFormat: Container.config.defaultDateFormat
77+
} as ICommitFormatOptions);
7578

7679
if (this.view.config.avatars) {
7780
item.iconPath = this.commit.getGravatarUri(Container.config.defaultGravatarsStyle);

src/views/nodes/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class MessageNode extends ViewNode {
1010
view: View,
1111
parent: ViewNode,
1212
private readonly _message: string,
13+
private readonly _description?: string,
1314
private readonly _tooltip?: string,
1415
private readonly _iconPath?:
1516
| string
@@ -30,6 +31,7 @@ export class MessageNode extends ViewNode {
3031
getTreeItem(): TreeItem | Promise<TreeItem> {
3132
const item = new TreeItem(this._message, TreeItemCollapsibleState.None);
3233
item.contextValue = ResourceType.Message;
34+
item.description = this._description;
3335
item.tooltip = this._tooltip;
3436
item.iconPath = this._iconPath;
3537
return item;
@@ -42,6 +44,7 @@ export class CommandMessageNode extends MessageNode {
4244
parent: ViewNode,
4345
private readonly _command: Command,
4446
message: string,
47+
description?: string,
4548
tooltip?: string,
4649
iconPath?:
4750
| string
@@ -52,7 +55,7 @@ export class CommandMessageNode extends MessageNode {
5255
}
5356
| ThemeIcon
5457
) {
55-
super(view, parent, message, tooltip, iconPath);
58+
super(view, parent, message, description, tooltip, iconPath);
5659
}
5760

5861
getTreeItem(): TreeItem | Promise<TreeItem> {

src/views/nodes/comparePickerNode.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
33
import { GlyphChars } from '../../constants';
44
import { Container } from '../../container';
5-
import { Strings } from '../../system';
65
import { CompareView } from '../compareView';
76
import { CompareNode } from './compareNode';
87
import { ResourceType, unknownGitUri, ViewNode } from './viewNode';
@@ -23,21 +22,22 @@ export class ComparePickerNode extends ViewNode<CompareView> {
2322
const selectedRef = this.parent.selectedRef;
2423
const repoPath = selectedRef !== undefined ? selectedRef.repoPath : undefined;
2524

26-
let repository = '';
25+
let description;
2726
if (repoPath !== undefined) {
2827
if ((await Container.git.getRepositoryCount()) > 1) {
2928
const repo = await Container.git.getRepository(repoPath);
30-
repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || repoPath}`;
29+
description = (repo && repo.formattedName) || repoPath;
3130
}
3231
}
3332

3433
let item;
3534
if (selectedRef === undefined) {
3635
item = new TreeItem(
37-
`Compare <branch, tag, or ref> with <branch, tag, or ref>${repository}`,
36+
`Compare <branch, tag, or ref> with <branch, tag, or ref>`,
3837
TreeItemCollapsibleState.None
3938
);
4039
item.contextValue = ResourceType.ComparePicker;
40+
item.description = description;
4141
item.tooltip = `Click to select branch or tag for compare${GlyphChars.Ellipsis}`;
4242
item.command = {
4343
title: `Select branch or tag for compare${GlyphChars.Ellipsis}`,
@@ -46,10 +46,11 @@ export class ComparePickerNode extends ViewNode<CompareView> {
4646
}
4747
else {
4848
item = new TreeItem(
49-
`Compare ${selectedRef.label} with <branch, tag, or ref>${repository}`,
49+
`Compare ${selectedRef.label} with <branch, tag, or ref>`,
5050
TreeItemCollapsibleState.None
5151
);
5252
item.contextValue = ResourceType.ComparePickerWithRef;
53+
item.description = description;
5354
item.tooltip = `Click to compare ${selectedRef.label} with${GlyphChars.Ellipsis}`;
5455
item.command = {
5556
title: `Compare ${selectedRef.label} with${GlyphChars.Ellipsis}`,

src/views/nodes/compareResultsNode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
3-
import { GlyphChars } from '../../constants';
43
import { Container } from '../../container';
54
import { GitService, GitUri } from '../../git/gitService';
65
import { Strings } from '../../system';
@@ -40,19 +39,20 @@ export class CompareResultsNode extends ViewNode {
4039
}
4140

4241
async getTreeItem(): Promise<TreeItem> {
43-
let repository = '';
42+
let description;
4443
if ((await Container.git.getRepositoryCount()) > 1) {
4544
const repo = await Container.git.getRepository(this.uri.repoPath!);
46-
repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`;
45+
description = (repo && repo.formattedName) || this.uri.repoPath;
4746
}
4847

4948
const item = new TreeItem(
5049
`Comparing ${this._ref1.label ||
5150
GitService.shortenSha(this._ref1.ref, { working: 'Working Tree' })} to ${this._ref2.label ||
52-
GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}${repository}`,
51+
GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}`,
5352
TreeItemCollapsibleState.Collapsed
5453
);
5554
item.contextValue = ResourceType.CompareResults;
55+
item.description = description;
5656

5757
return item;
5858
}

0 commit comments

Comments
 (0)