Skip to content

Commit

Permalink
Fixes parsing issue with certain renamed files
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 9, 2019
1 parent c5c7254 commit 66a9e65
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/git/parsers/logParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const diffRangeRegex = /^@@ -(\d+?),(\d+?) \+(\d+?),(\d+?) @@/;
export const fileStatusRegex = /(\S)\S*\t([^\t\n]+)(?:\t(.+))?/;
const fileStatusAndSummaryRegex = /^(\d+?|-)\s+?(\d+?|-)\s+?(.*)(?:\n\s(delete|rename|create))?/;
const fileStatusAndSummaryRenamedFileRegex = /(.+)\s=>\s(.+)/;
const fileStatusAndSummaryRenamedFilePathRegex = /(.*?){(.+?)\s=>\s(.+?)}(.*)/;
const fileStatusAndSummaryRenamedFilePathRegex = /(.*?){(.+?)\s=>\s(.*?)}(.*)/;

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

0 comments on commit 66a9e65

Please sign in to comment.