Overhauls timeline display to stream in results

Implements many API review changes
Fixes #89558
This commit is contained in:
Eric Amodio
2020-02-05 18:16:25 -05:00
parent 1db20bbb60
commit 4cc5b776dc
9 changed files with 361 additions and 296 deletions

View File

@@ -6,7 +6,7 @@
import * as dayjs from 'dayjs';
import * as advancedFormat from 'dayjs/plugin/advancedFormat';
import * as relativeTime from 'dayjs/plugin/relativeTime';
import { CancellationToken, Disposable, Event, EventEmitter, ThemeIcon, TimelineItem, TimelineProvider, Uri, workspace } from 'vscode';
import { CancellationToken, Disposable, Event, EventEmitter, ThemeIcon, TimelineItem, TimelineProvider, Uri, workspace, TimelineChangeEvent } from 'vscode';
import { Model } from './model';
import { Repository } from './repository';
import { debounce } from './decorators';
@@ -19,13 +19,13 @@ dayjs.extend(relativeTime);
// TODO[ECA]: Localize or use a setting for date format
export class GitTimelineProvider implements TimelineProvider {
private _onDidChange = new EventEmitter<Uri | undefined>();
get onDidChange(): Event<Uri | undefined> {
private _onDidChange = new EventEmitter<TimelineChangeEvent>();
get onDidChange(): Event<TimelineChangeEvent> {
return this._onDidChange.event;
}
readonly source = 'git-history';
readonly sourceDescription = 'Git History';
readonly id = 'git-history';
readonly label = 'Git History';
private _disposable: Disposable;
@@ -82,19 +82,18 @@ export class GitTimelineProvider implements TimelineProvider {
dateFormatter = dayjs(c.authorDate);
return {
id: c.hash,
timestamp: c.authorDate?.getTime() ?? 0,
iconPath: new (ThemeIcon as any)('git-commit'),
label: message,
description: `${dateFormatter.fromNow()} \u2022 ${c.authorName}`,
detail: `${c.authorName} (${c.authorEmail}) \u2014 ${c.hash.substr(0, 8)}\n${dateFormatter.fromNow()} (${dateFormatter.format('MMMM Do, YYYY h:mma')})\n\n${c.message}`,
command: {
title: 'Open Diff',
command: 'git.openDiff',
arguments: [uri, c.hash]
}
const item = new TimelineItem(message, c.authorDate?.getTime() ?? 0);
item.id = c.hash;
item.iconPath = new (ThemeIcon as any)('git-commit');
item.description = `${dateFormatter.fromNow()} \u2022 ${c.authorName}`;
item.detail = `${c.authorName} (${c.authorEmail}) \u2014 ${c.hash.substr(0, 8)}\n${dateFormatter.fromNow()} (${dateFormatter.format('MMMM Do, YYYY h:mma')})\n\n${c.message}`;
item.command = {
title: 'Open Diff',
command: 'git.openDiff',
arguments: [uri, c.hash]
};
return item;
});
const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
@@ -124,21 +123,19 @@ export class GitTimelineProvider implements TimelineProvider {
break;
}
const item = new TimelineItem('Staged Changes', date.getTime());
item.id = '~';
// TODO[ECA]: Replace with a better icon -- reflecting its status maybe?
item.iconPath = new (ThemeIcon as any)('git-commit');
item.description = `${dateFormatter.fromNow()} \u2022 You`;
item.detail = `You \u2014 Index\n${dateFormatter.fromNow()} (${dateFormatter.format('MMMM Do, YYYY h:mma')})\n${status}`;
item.command = {
title: 'Open Comparison',
command: 'git.openDiff',
arguments: [uri, '~']
};
items.push({
id: '~',
timestamp: date.getTime(),
// TODO[ECA]: Replace with a better icon -- reflecting its status maybe?
iconPath: new (ThemeIcon as any)('git-commit'),
label: 'Staged Changes',
description: `${dateFormatter.fromNow()} \u2022 You`,
detail: `You \u2014 Index\n${dateFormatter.fromNow()} (${dateFormatter.format('MMMM Do, YYYY h:mma')})\n${status}`,
command: {
title: 'Open Comparison',
command: 'git.openDiff',
arguments: [uri, '~']
}
});
items.push(item);
}
return items;