This commit is contained in:
Eric Amodio 2020-10-09 02:31:48 -04:00
parent f5d3ba4d61
commit d8b1776ccb
3 changed files with 40 additions and 3 deletions

View file

@ -1900,6 +1900,25 @@
},
"git.githubAuthentication": {
"deprecationMessage": "This setting is now deprecated, please use `github.gitAuthentication` instead."
},
"git.timeline.date": {
"enum": [
"committed",
"authored"
],
"enumDescriptions": [
"%config.date.committed%",
"%config.date.authored%"
],
"default": "committed",
"description": "%config.timeline.date%",
"scope": "window"
},
"git.timeline.showAuthor": {
"type": "boolean",
"default": true,
"description": "%config.timeline.showAuthor%",
"scope": "window"
}
}
},

View file

@ -158,6 +158,10 @@
"config.untrackedChanges.hidden": "Untracked changes are hidden and excluded from several actions.",
"config.showCommitInput": "Controls whether to show the commit input in the Git source control panel.",
"config.terminalAuthentication": "Controls whether to enable VS Code to be the authentication handler for git processes spawned in the integrated terminal. Note: terminals need to be restarted to pick up a change in this setting.",
"config.timeline.showAuthor": "Controls whether to show the commit author in the Timeline view",
"config.timeline.date": "Controls which date to use for items in the Timeline view",
"config.timeline.date.committed": "Use the committed date",
"config.timeline.date.authored": "Use the authored date",
"submenu.commit": "Commit",
"submenu.commit.amend": "Amend",
"submenu.commit.signoff": "Sign Off",

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
import { CancellationToken, Disposable, env, Event, EventEmitter, ThemeIcon, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider, Uri, workspace } from 'vscode';
import { CancellationToken, ConfigurationChangeEvent, Disposable, env, Event, EventEmitter, ThemeIcon, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider, Uri, workspace } from 'vscode';
import { Model } from './model';
import { Repository, Resource } from './repository';
import { debounce } from './decorators';
@ -75,6 +75,7 @@ export class GitTimelineProvider implements TimelineProvider {
constructor(private readonly model: Model) {
this.disposable = Disposable.from(
model.onDidOpenRepository(this.onRepositoriesChanged, this),
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this)
);
if (model.repositories.length) {
@ -110,6 +111,8 @@ export class GitTimelineProvider implements TimelineProvider {
);
}
const config = workspace.getConfiguration('git.timeline');
// TODO@eamodio: Ensure that the uri is a file -- if not we could get the history of the repo?
let limit: number | undefined;
@ -146,12 +149,17 @@ export class GitTimelineProvider implements TimelineProvider {
const dateFormatter = new Intl.DateTimeFormat(env.language, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' });
const dateType = config.get<'committed' | 'authored'>('date');
const showAuthor = config.get<boolean>('showAuthor');
const items = commits.map<GitTimelineItem>((c, i) => {
const date = c.commitDate; // c.authorDate
const date = dateType === 'authored' ? c.authorDate : c.commitDate;
const item = new GitTimelineItem(c.hash, commits[i + 1]?.hash ?? `${c.hash}^`, c.message, date?.getTime() ?? 0, c.hash, 'git:file:commit');
item.iconPath = new (ThemeIcon as any)('git-commit');
item.description = c.authorName;
if (showAuthor) {
item.description = c.authorName;
}
item.detail = `${c.authorName} (${c.authorEmail}) — ${c.hash.substr(0, 8)}\n${dateFormatter.format(date)}\n\n${c.message}`;
item.command = {
title: 'Open Comparison',
@ -214,6 +222,12 @@ export class GitTimelineProvider implements TimelineProvider {
}
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (e.affectsConfiguration('git.timeline.date') || e.affectsConfiguration('git.timeline.showAuthor')) {
this.fireChanged();
}
}
private onRepositoriesChanged(_repo: Repository) {
// console.log(`GitTimelineProvider.onRepositoriesChanged`);