Skip to content

Commit 8291a3d

Browse files
committed
Adds contributor stats to description when enabled
1 parent 08a9ff1 commit 8291a3d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/views/nodes/contributorNode.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
8585
async getTreeItem(): Promise<TreeItem> {
8686
const presence = this.options?.presence?.get(this.contributor.email!);
8787

88+
const numberFormatter = new Intl.NumberFormat();
89+
90+
const shortStats =
91+
this.contributor.stats != null
92+
? ` (${pluralize('file', this.contributor.stats.files, {
93+
format: numberFormatter.format,
94+
})}, +${numberFormatter.format(this.contributor.stats.additions)} -${numberFormatter.format(
95+
this.contributor.stats.additions,
96+
)} ${pluralize('line', this.contributor.stats.additions + this.contributor.stats.deletions, {
97+
only: true,
98+
})})`
99+
: '';
100+
88101
const item = new TreeItem(
89102
this.contributor.current ? `${this.contributor.label} (you)` : this.contributor.label,
90103
TreeItemCollapsibleState.Collapsed,
@@ -100,7 +113,10 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
100113
}${this.contributor.date != null ? `${this.contributor.formatDateFromNow()}, ` : ''}${pluralize(
101114
'commit',
102115
this.contributor.count,
103-
)}`;
116+
{
117+
format: numberFormatter.format,
118+
},
119+
)}${shortStats}`;
104120

105121
let avatarUri;
106122
let avatarMarkdown;
@@ -128,8 +144,6 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
128144
}
129145
}
130146

131-
const numberFormatter = new Intl.NumberFormat();
132-
133147
const stats =
134148
this.contributor.stats != null
135149
? `\\\n${pluralize('file', this.contributor.stats.files, {

0 commit comments

Comments
 (0)