diff --git a/extensions/git/src/historyProvider.ts b/extensions/git/src/historyProvider.ts index d13f85a5d46..c23a7c29f7d 100644 --- a/extensions/git/src/historyProvider.ts +++ b/extensions/git/src/historyProvider.ts @@ -127,15 +127,12 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec await ensureEmojis(); return commits.map(commit => { - const newLineIndex = commit.message.indexOf('\n'); - const subject = newLineIndex !== -1 ? commit.message.substring(0, newLineIndex) : commit.message; - const labels = this.resolveHistoryItemLabels(commit); return { id: commit.hash, parentIds: commit.parents, - message: emojify(subject), + message: emojify(commit.message), author: commit.authorName, icon: new ThemeIcon('git-commit'), displayId: commit.hash.substring(0, 8), diff --git a/src/vs/workbench/api/browser/mainThreadSCM.ts b/src/vs/workbench/api/browser/mainThreadSCM.ts index 649cef3ce77..cc021cfa639 100644 --- a/src/vs/workbench/api/browser/mainThreadSCM.ts +++ b/src/vs/workbench/api/browser/mainThreadSCM.ts @@ -46,7 +46,11 @@ function toISCMHistoryItem(historyItemDto: SCMHistoryItemDto): ISCMHistoryItem { title: l.title, icon: getIconFromIconDto(l.icon) })); - return { ...historyItemDto, labels }; + const newLineIndex = historyItemDto.message.indexOf('\n'); + const subject = newLineIndex === -1 ? + historyItemDto.message : `${historyItemDto.message.substring(0, newLineIndex)}\u2026`; + + return { ...historyItemDto, subject, labels }; } class SCMInputBoxContentProvider extends Disposable implements ITextModelContentProvider { diff --git a/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts index d765da1afe3..73d33cddb0a 100644 --- a/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts @@ -235,7 +235,7 @@ class HistoryItemRenderer implements ITreeRenderer { @@ -26,8 +30,8 @@ suite('toISCMHistoryItemViewModelArray', () => { test('single commit', () => { const models = [ - { id: 'a', parentIds: [], message: '' }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', []), + ]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -46,12 +50,12 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('linear graph', () => { const models = [ - { id: 'a', parentIds: ['b'] }, - { id: 'b', parentIds: ['c'] }, - { id: 'c', parentIds: ['d'] }, - { id: 'd', parentIds: ['e'] }, - { id: 'e', parentIds: [] }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b']), + toSCMHistoryItem('b', ['c']), + toSCMHistoryItem('c', ['d']), + toSCMHistoryItem('d', ['e']), + toSCMHistoryItem('e', []), + ]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -110,12 +114,12 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('merge commit (single commit in topic branch)', () => { const models = [ - { id: 'a', parentIds: ['b'] }, - { id: 'b', parentIds: ['c', 'd'] }, - { id: 'd', parentIds: ['c'] }, - { id: 'c', parentIds: ['e'] }, - { id: 'e', parentIds: ['f'] }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b']), + toSCMHistoryItem('b', ['c', 'd']), + toSCMHistoryItem('d', ['c']), + toSCMHistoryItem('c', ['e']), + toSCMHistoryItem('e', ['f']), + ]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -184,13 +188,13 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('merge commit (multiple commits in topic branch)', () => { const models = [ - { id: 'a', parentIds: ['b', 'c'] }, - { id: 'c', parentIds: ['d'] }, - { id: 'b', parentIds: ['e'] }, - { id: 'e', parentIds: ['f'] }, - { id: 'f', parentIds: ['d'] }, - { id: 'd', parentIds: ['g'] }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b', 'c']), + toSCMHistoryItem('c', ['d']), + toSCMHistoryItem('b', ['e']), + toSCMHistoryItem('e', ['f']), + toSCMHistoryItem('f', ['d']), + toSCMHistoryItem('d', ['g']), + ]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -282,13 +286,13 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('create brach from merge commit', () => { const models = [ - { id: 'a', parentIds: ['b', 'c'] }, - { id: 'c', parentIds: ['b'] }, - { id: 'b', parentIds: ['d', 'e'] }, - { id: 'e', parentIds: ['f'] }, - { id: 'f', parentIds: ['g'] }, - { id: 'd', parentIds: ['h'] }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b', 'c']), + toSCMHistoryItem('c', ['b']), + toSCMHistoryItem('b', ['d', 'e']), + toSCMHistoryItem('e', ['f']), + toSCMHistoryItem('f', ['g']), + toSCMHistoryItem('d', ['h']), + ]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -387,14 +391,14 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('create multiple branches from a commit', () => { const models = [ - { id: 'a', parentIds: ['b', 'c'] }, - { id: 'c', parentIds: ['d'] }, - { id: 'b', parentIds: ['e', 'f'] }, - { id: 'f', parentIds: ['g'] }, - { id: 'e', parentIds: ['g'] }, - { id: 'd', parentIds: ['g'] }, - { id: 'g', parentIds: ['h'] }, - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b', 'c']), + toSCMHistoryItem('c', ['d']), + toSCMHistoryItem('b', ['e', 'f']), + toSCMHistoryItem('f', ['g']), + toSCMHistoryItem('e', ['g']), + toSCMHistoryItem('d', ['g']), + toSCMHistoryItem('g', ['h']), + ] satisfies ISCMHistoryItem[]; const viewModels = toISCMHistoryItemViewModelArray(models); @@ -513,13 +517,13 @@ suite('toISCMHistoryItemViewModelArray', () => { */ test('graph with color map', () => { const models = [ - { id: 'a', parentIds: ['b'], labels: [{ title: 'topic' }] }, - { id: 'b', parentIds: ['c'] }, - { id: 'c', parentIds: ['d'], labels: [{ title: 'origin/topic' }] }, - { id: 'd', parentIds: ['e'] }, - { id: 'e', parentIds: ['f', 'g'] }, - { id: 'g', parentIds: ['h'], labels: [{ title: 'origin/main' }] } - ] as ISCMHistoryItem[]; + toSCMHistoryItem('a', ['b'], [{ title: 'topic' }]), + toSCMHistoryItem('b', ['c']), + toSCMHistoryItem('c', ['d'], [{ title: 'origin/topic' }]), + toSCMHistoryItem('d', ['e']), + toSCMHistoryItem('e', ['f', 'g']), + toSCMHistoryItem('g', ['h'], [{ title: 'origin/main' }]) + ]; const colorMap = new Map([ ['topic', historyItemGroupLocal],