Skip to content

Commit

Permalink
Adds contributor stats to description when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 21, 2024
1 parent 08a9ff1 commit 8291a3d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/views/nodes/contributorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
async getTreeItem(): Promise<TreeItem> {
const presence = this.options?.presence?.get(this.contributor.email!);

const numberFormatter = new Intl.NumberFormat();

const shortStats =
this.contributor.stats != null
? ` (${pluralize('file', this.contributor.stats.files, {
format: numberFormatter.format,
})}, +${numberFormatter.format(this.contributor.stats.additions)} -${numberFormatter.format(
this.contributor.stats.additions,
)} ${pluralize('line', this.contributor.stats.additions + this.contributor.stats.deletions, {
only: true,
})})`
: '';

const item = new TreeItem(
this.contributor.current ? `${this.contributor.label} (you)` : this.contributor.label,
TreeItemCollapsibleState.Collapsed,
Expand All @@ -100,7 +113,10 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
}${this.contributor.date != null ? `${this.contributor.formatDateFromNow()}, ` : ''}${pluralize(
'commit',
this.contributor.count,
)}`;
{
format: numberFormatter.format,
},
)}${shortStats}`;

let avatarUri;
let avatarMarkdown;
Expand Down Expand Up @@ -128,8 +144,6 @@ export class ContributorNode extends ViewNode<'contributor', ViewsWithContributo
}
}

const numberFormatter = new Intl.NumberFormat();

const stats =
this.contributor.stats != null
? `\\\n${pluralize('file', this.contributor.stats.files, {
Expand Down

0 comments on commit 8291a3d

Please sign in to comment.