Skip to content

Commit fe884b3

Browse files
committed
Revert "Revert "Fix microsoft#88294 Add commitData in commit interface""
This reverts commit aa70f38.
1 parent 70b5e93 commit fe884b3

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

extensions/git/src/api/git.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface Commit {
4444
readonly authorDate?: Date;
4545
readonly authorName?: string;
4646
readonly authorEmail?: string;
47+
readonly commitDate?: Date;
4748
}
4849

4950
export interface Submodule {

extensions/git/src/git.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function sanitizePath(path: string): string {
333333
return path.replace(/^([a-z]):\\/i, (_, letter) => `${letter.toUpperCase()}:\\`);
334334
}
335335

336-
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%P%n%B';
336+
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%B';
337337

338338
export class Git {
339339

@@ -525,6 +525,7 @@ export interface Commit {
525525
authorDate?: Date;
526526
authorName?: string;
527527
authorEmail?: string;
528+
commitDate?: Date;
528529
}
529530

530531
export class GitStatusParser {
@@ -655,15 +656,16 @@ export function parseGitmodules(raw: string): Submodule[] {
655656
return result;
656657
}
657658

658-
const commitRegex = /([0-9a-f]{40})\n(.*)\n(.*)\n(.*)\n(.*)(?:\n([^]*?))?(?:\x00)/gm;
659+
const commitRegex = /([0-9a-f]{40})\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)(?:\n([^]*?))?(?:\x00)/gm;
659660

660661
export function parseGitCommits(data: string): Commit[] {
661662
let commits: Commit[] = [];
662663

663664
let ref;
664-
let name;
665-
let email;
666-
let date;
665+
let authorName;
666+
let authorEmail;
667+
let authorDate;
668+
let commitDate;
667669
let parents;
668670
let message;
669671
let match;
@@ -674,7 +676,7 @@ export function parseGitCommits(data: string): Commit[] {
674676
break;
675677
}
676678

677-
[, ref, name, email, date, parents, message] = match;
679+
[, ref, authorName, authorEmail, authorDate, commitDate, parents, message] = match;
678680

679681
if (message[message.length - 1] === '\n') {
680682
message = message.substr(0, message.length - 1);
@@ -685,9 +687,10 @@ export function parseGitCommits(data: string): Commit[] {
685687
hash: ` ${ref}`.substr(1),
686688
message: ` ${message}`.substr(1),
687689
parents: parents ? parents.split(' ') : [],
688-
authorDate: new Date(Number(date) * 1000),
689-
authorName: ` ${name}`.substr(1),
690-
authorEmail: ` ${email}`.substr(1)
690+
authorDate: new Date(Number(authorDate) * 1000),
691+
authorName: ` ${authorName}`.substr(1),
692+
authorEmail: ` ${authorEmail}`.substr(1),
693+
commitDate: new Date(Number(commitDate) * 1000),
691694
});
692695
} while (true);
693696

0 commit comments

Comments
 (0)