parse-diff
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -39,2 +39,30 @@ const parse = require("../index"); | ||
it("should parse simple git-like diff with file enclosed by double-quote", function() { | ||
const diff = `\ | ||
diff --git "a/file1" "b/file2" | ||
similarity index 100% | ||
rename from "file1" | ||
rename to "file2"\ | ||
`; | ||
const files = parse(diff); | ||
expect(files.length).toBe(1); | ||
const file = files[0]; | ||
expect(file.from).toBe("file1"); | ||
expect(file.to).toBe("file2"); | ||
expect(file.chunks.length).toBe(0); | ||
}); | ||
it('should parse file names for changed binaries with spaces in their names', function() { | ||
const diff = `\ | ||
diff --git a/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png b/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png | ||
index fc72ba34b..ec373e9a4 100644 | ||
Binary files a/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png and b/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png differ\ | ||
`; | ||
const files = parse(diff); | ||
expect(files.length).toBe(1) | ||
const file = files[0] | ||
expect(file.from).toBe("Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png") | ||
expect(file.to).toBe("Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png") | ||
}); | ||
it("should parse diff with new file mode line", function() { | ||
@@ -41,0 +69,0 @@ const diff = `\ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.1 | ||
// parses unified diff | ||
@@ -157,5 +157,5 @@ // http://www.gnu.org/software/diffutils/manual/diffutils.html#Unified-Format | ||
} | ||
fileNames = s.match(/a\/.*(?= b)|b\/.*$/g); | ||
fileNames = s.match(/a\/.*(?=["']? ["']?b\/)|b\/.*$/g); | ||
fileNames.map(function(fileName, i) { | ||
return fileNames[i] = fileName.replace(/^(a|b)\//, ''); | ||
return fileNames[i] = fileName.replace(/^(a|b)\//, '').replace(/("|')$/, ''); | ||
}); | ||
@@ -162,0 +162,0 @@ return fileNames; |
{ | ||
"name": "parse-diff", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Unified diff parser", | ||
@@ -20,4 +20,4 @@ "author": "Sergey Todyshev <stodyshev@gmail.com>", | ||
"coffeelint": "^2.1.0", | ||
"coffeescript": "^2.4.1", | ||
"jest": "^24.9.0" | ||
"coffeescript": "^2.5.1", | ||
"jest": "^25.1.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
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
24176
607