gitdiff-parser
Advanced tools
Comparing version 0.3.0 to 0.3.1
53
index.js
@@ -11,3 +11,41 @@ /** | ||
function parsePathFromFirstLine(line) { | ||
var filesStr = line.slice(11); | ||
var oldPath = null; | ||
var newPath = null; | ||
var quoteIndex = filesStr.indexOf('"'); | ||
switch (quoteIndex) { | ||
case -1: | ||
var segs = filesStr.split(' '); | ||
oldPath = segs[0].slice(2); | ||
newPath = segs[1].slice(2); | ||
break; | ||
case 0: | ||
var nextQuoteIndex = filesStr.indexOf('"', 2); | ||
oldPath = filesStr.slice(3, nextQuoteIndex); | ||
var newQuoteIndex = filesStr.indexOf('"', nextQuoteIndex + 1); | ||
if (newQuoteIndex < 0) { | ||
newPath = filesStr.slice(nextQuoteIndex + 4); | ||
} | ||
else { | ||
newPath = filesStr.slice(newQuoteIndex + 3, -1); | ||
} | ||
break; | ||
default: | ||
var segs = filesStr.split(' '); | ||
oldPath = segs[0].slice(2); | ||
newPath = segs[1].slice(3, -1); | ||
break; | ||
} | ||
return { | ||
oldPath: oldPath, | ||
newPath: newPath | ||
}; | ||
} | ||
var parser = { | ||
@@ -27,2 +65,3 @@ /** | ||
var changeNewLine; | ||
var paths; | ||
@@ -39,6 +78,9 @@ | ||
// read file | ||
paths = parsePathFromFirstLine(line); | ||
currentInfo = { | ||
hunks: [], | ||
oldEndingNewLine: true, | ||
newEndingNewLine: true | ||
newEndingNewLine: true, | ||
oldPath: paths.oldPath, | ||
newPath: paths.newPath | ||
}; | ||
@@ -90,3 +132,2 @@ | ||
break; | ||
@@ -121,4 +162,8 @@ case 'copy': | ||
currentInfo.oldPath = oldPath; | ||
currentInfo.newPath = newPath; | ||
if (oldPath) { | ||
currentInfo.oldPath = oldPath; | ||
} | ||
if (newPath) { | ||
currentInfo.newPath = newPath; | ||
} | ||
stat = STAT_HUNK; | ||
@@ -125,0 +170,0 @@ break simiLoop; |
{ | ||
"name": "gitdiff-parser", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13675
269
0