Git - 💄 clean-up summary generation (#202036)

This commit is contained in:
Ladislau Szomoru 2024-01-08 20:50:42 +01:00 committed by GitHub
parent e1f8dddce9
commit 66023e11e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,14 +81,16 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
const refParentId = options.limit.id;
const refId = await this.repository.revParse(historyItemGroupId) ?? '';
const [summary, commits] = await Promise.all([
this.getSummaryHistoryItem(refId, refParentId),
this.repository.log({ range: `${refParentId}..${refId}`, shortStats: true, sortByAuthorDate: true })
]);
const historyItems: SourceControlHistoryItem[] = [];
const commits = await this.repository.log({ range: `${refParentId}..${refId}`, shortStats: true, sortByAuthorDate: true });
if (commits.length >= 2) {
const allChanges = await this.repository.diffBetweenShortStat(refParentId, refId);
historyItems.push({ id: refId, parentIds: [refParentId], icon: new ThemeIcon('files'), label: l10n.t('All Changes'), statistics: allChanges });
}
await ensureEmojis();
const historyItems = commits.length < 2 ? [] : [summary];
historyItems.push(...commits.map(commit => {
const newLineIndex = commit.message.indexOf('\n');
const subject = newLineIndex !== -1 ? commit.message.substring(0, newLineIndex) : commit.message;
@ -203,11 +205,6 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
return new FileDecoration(letter, tooltip, color);
}
private async getSummaryHistoryItem(refId: string, refParentId: string): Promise<SourceControlHistoryItem> {
const statistics = await this.repository.diffBetweenShortStat(refParentId, refId);
return { id: refId, parentIds: [refParentId], icon: new ThemeIcon('files'), label: l10n.t('All Changes'), statistics };
}
dispose(): void {
this.disposables.forEach(d => d.dispose());
}