diff --git a/README.md b/README.md
index ac90d1c..a374ebb 100644
--- a/README.md
+++ b/README.md
@@ -652,6 +652,7 @@ GitLens is highly customizable and provides many configuration settings to allow
| `gitlens.defaultDateFormat` | Specifies how absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.defaultDateShortFormat` | Specifies how short absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.defaultDateStyle` | Specifies how dates will be displayed by default |
+| `gitlens.defaultDateType` | Specifies if dates should use author date or committer date |
| `gitlens.defaultGravatarsStyle` | Specifies the style of the gravatar default (fallback) images
`identicon` - a geometric pattern
`mm` - a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)
`monsterid` - a monster with different colors, faces, etc
`retro` - 8-bit arcade-style pixelated faces
`robohash` - a robot with different colors, faces, etc
`wavatar` - a face with differing features and backgrounds |
| `gitlens.insiders` | Specifies whether to enable experimental features |
| `gitlens.keymap` | Specifies the keymap to use for GitLens shortcut keys
`alternate` - adds an alternate set of shortcut keys that start with `Alt` (⌥ on macOS)
`chorded` - adds a chorded set of shortcut keys that start with `Ctrl+Shift+G` (⌥⌘G
on macOS)
`none` - no shortcut keys will be added |
diff --git a/package.json b/package.json
index 2ef511c..1703479 100644
--- a/package.json
+++ b/package.json
@@ -439,6 +439,20 @@
"markdownDescription": "Specifies how dates will be displayed by default",
"scope": "window"
},
+ "gitlens.defaultDateType": {
+ "type": "string",
+ "default": "author",
+ "enum": [
+ "author",
+ "committer"
+ ],
+ "enumDescriptions": [
+ "The date that the commit was originally written",
+ "The date that the commit was applied to the branch"
+ ],
+ "markdownDescription": "Specifies if dates should use author date or committer date",
+ "scope": "window"
+ },
"gitlens.defaultGravatarsStyle": {
"type": "string",
"default": "robohash",
diff --git a/src/codelens/codeLensController.ts b/src/codelens/codeLensController.ts
index 9c2c32d..bfbded8 100644
--- a/src/codelens/codeLensController.ts
+++ b/src/codelens/codeLensController.ts
@@ -32,7 +32,8 @@ export class GitCodeLensController implements Disposable {
if (
configuration.changed(e, section, null) ||
configuration.changed(e, configuration.name('defaultDateStyle').value) ||
- configuration.changed(e, configuration.name('defaultDateFormat').value)
+ configuration.changed(e, configuration.name('defaultDateFormat').value) ||
+ configuration.changed(e, configuration.name('defaultDateType').value)
) {
if (!configuration.initializing(e)) {
Logger.log('CodeLens config changed; resetting CodeLens provider');
diff --git a/src/config.ts b/src/config.ts
index 4eab7d9..5be13ed 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -30,6 +30,7 @@ export interface Config {
defaultDateFormat: string | null;
defaultDateShortFormat: string | null;
defaultDateStyle: DateStyle;
+ defaultDateType: DateType;
defaultGravatarsStyle: GravatarDefaultStyle;
heatmap: {
ageThreshold: number;
@@ -127,6 +128,11 @@ export enum CustomRemoteType {
GitLab = 'GitLab'
}
+export enum DateType {
+ Author = 'author',
+ Committer = 'committer'
+}
+
export enum DateStyle {
Absolute = 'absolute',
Relative = 'relative'
diff --git a/src/git/gitService.ts b/src/git/gitService.ts
index 9a7838b..2a2600c 100644
--- a/src/git/gitService.ts
+++ b/src/git/gitService.ts
@@ -168,7 +168,8 @@ export class GitService implements Disposable {
private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (
configuration.changed(e, configuration.name('defaultDateStyle').value) ||
- configuration.changed(e, configuration.name('defaultDateFormat').value)
+ configuration.changed(e, configuration.name('defaultDateFormat').value) ||
+ configuration.changed(e, configuration.name('defaultDateType').value)
) {
CommitFormatting.reset();
}
diff --git a/src/git/models/blameCommit.ts b/src/git/models/blameCommit.ts
index d333e72..000eeb4 100644
--- a/src/git/models/blameCommit.ts
+++ b/src/git/models/blameCommit.ts
@@ -7,7 +7,8 @@ export class GitBlameCommit extends GitCommit {
sha: string,
author: string,
email: string | undefined,
- date: Date,
+ authorDate: Date,
+ committerDate: Date,
message: string,
fileName: string,
originalFileName: string | undefined,
@@ -21,7 +22,8 @@ export class GitBlameCommit extends GitCommit {
sha,
author,
email,
- date,
+ authorDate,
+ committerDate,
message,
fileName,
originalFileName,
@@ -49,7 +51,8 @@ export class GitBlameCommit extends GitCommit {
changes.sha || this.sha,
this.author,
this.email,
- this.date,
+ this.authorDate,
+ this.committerDate,
this.message,
changes.fileName || this.fileName,
this.getChangedValue(changes.originalFileName, this.originalFileName),
diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts
index 70e1411..97bbedf 100644
--- a/src/git/models/commit.ts
+++ b/src/git/models/commit.ts
@@ -7,6 +7,7 @@ import { CommitFormatter } from '../formatters/formatters';
import { Git } from '../git';
import { GitUri } from '../gitUri';
import { getGravatarUri } from '../../gravatar';
+import { DateType } from '../../config';
export interface GitAuthor {
name: string;
@@ -32,10 +33,12 @@ export enum GitCommitType {
export const CommitFormatting = {
dateFormat: undefined! as string | null,
dateStyle: undefined! as DateStyle,
+ dateType: undefined! as DateType,
reset: () => {
CommitFormatting.dateStyle = configuration.get(configuration.name('defaultDateStyle').value);
CommitFormatting.dateFormat = configuration.get(configuration.name('defaultDateFormat').value);
+ CommitFormatting.dateType = configuration.get(configuration.name('defaultDateType').value);
}
};
@@ -52,13 +55,17 @@ export abstract class GitCommit {
private _isUncommitted: boolean | undefined;
private _shortSha: string | undefined;
+ private _authorDateFormatter: Dates.DateFormatter | undefined;
+ private _committerDateFormatter: Dates.DateFormatter | undefined;
+
constructor(
type: GitCommitType,
public readonly repoPath: string,
public readonly sha: string,
public readonly author: string,
public readonly email: string | undefined,
- public readonly date: Date,
+ public readonly authorDate: Date,
+ public readonly committerDate: Date,
public readonly message: string,
fileName: string,
originalFileName?: string,
@@ -77,6 +84,30 @@ export abstract class GitCommit {
return this.isFile ? this._fileName : '';
}
+ get date(): Date {
+ return CommitFormatting.dateType === DateType.Committer
+ ? this.committerDate : this.authorDate;
+ }
+
+ get authorDateFormatter(): Dates.DateFormatter {
+ if (this._authorDateFormatter === undefined) {
+ this._authorDateFormatter = Dates.toFormatter(this.authorDate);
+ }
+ return this._authorDateFormatter;
+ }
+
+ get committerDateFormatter(): Dates.DateFormatter {
+ if (this._committerDateFormatter === undefined) {
+ this._committerDateFormatter = Dates.toFormatter(this.committerDate);
+ }
+ return this._committerDateFormatter;
+ }
+
+ get dateFormatter(): Dates.DateFormatter {
+ return CommitFormatting.dateType === DateType.Committer
+ ? this.committerDateFormatter : this.authorDateFormatter;
+ }
+
get formattedDate(): string {
return CommitFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(CommitFormatting.dateFormat)
@@ -149,24 +180,16 @@ export abstract class GitCommit {
return this.workingFileName ? GitUri.resolveToUri(this.workingFileName, this.repoPath) : this.uri;
}
- private _dateFormatter?: Dates.DateFormatter;
-
formatDate(format?: string | null) {
if (format == null) {
format = 'MMMM Do, YYYY h:mma';
}
- if (this._dateFormatter === undefined) {
- this._dateFormatter = Dates.toFormatter(this.date);
- }
- return this._dateFormatter.format(format);
+ return this.dateFormatter.format(format);
}
fromNow() {
- if (this._dateFormatter === undefined) {
- this._dateFormatter = Dates.toFormatter(this.date);
- }
- return this._dateFormatter.fromNow();
+ return this.dateFormatter.fromNow();
}
getFormattedPath(options: { relativeTo?: string; separator?: string; suffix?: string } = {}): string {
diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts
index d6384e0..38a3fea 100644
--- a/src/git/models/logCommit.ts
+++ b/src/git/models/logCommit.ts
@@ -35,6 +35,7 @@ export class GitLogCommit extends GitCommit {
author,
email,
date,
+ committedDate,
message,
fileName,
originalFileName,
diff --git a/src/git/parsers/blameParser.ts b/src/git/parsers/blameParser.ts
index 4c64223..686158f 100644
--- a/src/git/parsers/blameParser.ts
+++ b/src/git/parsers/blameParser.ts
@@ -18,6 +18,9 @@ interface BlameEntry {
authorTimeZone?: string;
authorEmail?: string;
+ committerDate?: string;
+ committerTimeZone?: string;
+
previousSha?: string;
previousFileName?: string;
@@ -107,6 +110,14 @@ export class GitBlameParser {
entry.authorTimeZone = lineParts[1];
break;
+ case 'committer-time':
+ entry.committerDate = lineParts[1];
+ break;
+
+ case 'committer-tz':
+ entry.committerTimeZone = lineParts[1];
+ break;
+
case 'summary':
entry.summary = lineParts
.slice(1)
@@ -207,6 +218,7 @@ export class GitBlameParser {
entry.author,
entry.authorEmail,
new Date((entry.authorDate as any) * 1000),
+ new Date((entry.committerDate as any) * 1000),
entry.summary!,
relativeFileName,
entry.previousFileName !== undefined && entry.previousFileName !== entry.fileName