From 9c2269b9f12713da437d02cbd5adb050ab6c95a3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 15 Mar 2017 12:06:54 -0400 Subject: [PATCH] Adds parent sha parsing --- src/git/enrichers/logParserEnricher.ts | 8 ++++++++ src/git/git.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/git/enrichers/logParserEnricher.ts b/src/git/enrichers/logParserEnricher.ts index 7d7847e..e3f8722 100644 --- a/src/git/enrichers/logParserEnricher.ts +++ b/src/git/enrichers/logParserEnricher.ts @@ -13,6 +13,8 @@ interface ILogEntry { committer?: string; committerDate?: string; + parentSha?: string; + fileName?: string; originalFileName?: string; fileStatuses?: { status: GitFileStatus, fileName: string, originalFileName: string }[]; @@ -70,6 +72,10 @@ export class GitLogParserEnricher implements IGitEnricher { // entry.committerDate = lineParts.slice(1).join(' ').trim(); // break; + case 'parent': + entry.parentSha = lineParts.slice(1).join(' ').trim(); + break; + case 'summary': entry.summary = lineParts.slice(1).join(' ').trim(); while (++position < lines.length) { @@ -209,8 +215,10 @@ export class GitLogParserEnricher implements IGitEnricher { if (recentCommit) { recentCommit.previousSha = commit.sha; + // If the commit sha's match (merge commit), just forward it along commit.nextSha = commit.sha !== recentCommit.sha ? recentCommit.sha : recentCommit.nextSha; + // Only add a filename if this is a file log if (type === 'file') { recentCommit.previousFileName = commit.originalFileName || commit.fileName; diff --git a/src/git/git.ts b/src/git/git.ts index 94e028d..dc3aa09 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -13,7 +13,7 @@ export * from './enrichers/logParserEnricher'; let git: IGit; const UncommittedRegex = /^[0]+$/; -const DefaultLogParams = [`log`, `--name-status`, `--full-history`, `-m`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %B%nfilename ?`]; +const DefaultLogParams = [`log`, `--name-status`, `--full-history`, `-m`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nparent %P%nsummary %B%nfilename ?`]; async function gitCommand(cwd: string, ...args: any[]) { try {