From 04c9fd25e583bb48e2b7cdd96613d6c3e5358fe9 Mon Sep 17 00:00:00 2001 From: Federico Bozzini Date: Thu, 20 Feb 2020 15:52:14 +0000 Subject: [PATCH] [git] Fixed duplicated entries for git history on merge operations Signed-off-by: Federico Bozzini --- packages/git/src/node/dugite-git.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/git/src/node/dugite-git.ts b/packages/git/src/node/dugite-git.ts index f1ff64aab230d..f2710ae639124 100644 --- a/packages/git/src/node/dugite-git.ts +++ b/packages/git/src/node/dugite-git.ts @@ -147,14 +147,23 @@ export class CommitDetailsParser extends OutputParser { for (const chunk of chunks) { const [sha, email, name, timestamp, authorDateRelative, summary, body, rawChanges] = chunk.trim().split(CommitDetailsParser.ENTRY_DELIMITER); const fileChanges = this.nameStatusParser.parse(repositoryUri, (rawChanges || '').trim()); - changes.push({ - sha, - author: { timestamp, email, name }, - authorDateRelative, - summary, - body, - fileChanges - }); + const shaChange = changes.find(c => c.sha === sha); + if (shaChange !== undefined) { + for (const fileChange of fileChanges) { + if (!shaChange.fileChanges.some(c => c.uri === fileChange.uri)) { + shaChange.fileChanges.push(fileChange); + } + } + } else { + changes.push({ + sha, + author: { timestamp, email, name }, + authorDateRelative, + summary, + body, + fileChanges + }); + } } return changes; }