Skip to content

Commit 66a9e65

Browse files
committed
Fixes parsing issue with certain renamed files
1 parent c5c7254 commit 66a9e65

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/git/parsers/logParser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const diffRangeRegex = /^@@ -(\d+?),(\d+?) \+(\d+?),(\d+?) @@/;
1414
export const fileStatusRegex = /(\S)\S*\t([^\t\n]+)(?:\t(.+))?/;
1515
const fileStatusAndSummaryRegex = /^(\d+?|-)\s+?(\d+?|-)\s+?(.*)(?:\n\s(delete|rename|create))?/;
1616
const fileStatusAndSummaryRenamedFileRegex = /(.+)\s=>\s(.+)/;
17-
const fileStatusAndSummaryRenamedFilePathRegex = /(.*?){(.+?)\s=>\s(.+?)}(.*)/;
17+
const fileStatusAndSummaryRenamedFilePathRegex = /(.*?){(.+?)\s=>\s(.*?)}(.*)/;
1818

1919
const logFileSimpleRegex = /^<r> (.*)\s*(?:(?:diff --git a\/(.*) b\/(.*))|(?:(\S)\S*\t([^\t\n]+)(?:\t(.+))?))/gm;
2020
const logFileSimpleRenamedRegex = /^<r> (\S+)\s*(.*)$/s;
@@ -272,7 +272,11 @@ export class GitLogParser {
272272
renamedFileName
273273
);
274274
if (renamedMatch != null) {
275-
entry.fileName = `${renamedMatch[1]}${renamedMatch[3]}${renamedMatch[4]}`;
275+
// If there is no new path, the path part was removed so ensure we don't end up with //
276+
entry.fileName =
277+
renamedMatch[3] === ''
278+
? `${renamedMatch[1]}${renamedMatch[4]}`.replace('//', '/')
279+
: `${renamedMatch[1]}${renamedMatch[3]}${renamedMatch[4]}`;
276280
entry.originalFileName = `${renamedMatch[1]}${renamedMatch[2]}${renamedMatch[4]}`;
277281
}
278282
else {

0 commit comments

Comments
 (0)