1. add test case. 2. fix typo error
This commit is contained in:
parent
5f0048ceaa
commit
1d5daa4138
2 changed files with 42 additions and 2 deletions
|
|
@ -455,7 +455,7 @@
|
||||||
* You proberly do not want to see the second record. So will provide an `ignoreSvnPropertyChange` option to do that for you.
|
* You proberly do not want to see the second record. So will provide an `ignoreSvnPropertyChange` option to do that for you.
|
||||||
*/
|
*/
|
||||||
function dropSvnPropertyChangeFiles(files) {
|
function dropSvnPropertyChangeFiles(files) {
|
||||||
const GIT_BINNARY_HEADER = 'GIT binary patch';
|
const GIT_BINARY_HEADER = 'GIT binary patch';
|
||||||
const PROPERTY_CHANGE_HEADER = 'Property changes on:';
|
const PROPERTY_CHANGE_HEADER = 'Property changes on:';
|
||||||
var ret = [];
|
var ret = [];
|
||||||
for (var i = 0; i < files.length - 1; i++) {
|
for (var i = 0; i < files.length - 1; i++) {
|
||||||
|
|
@ -464,7 +464,7 @@
|
||||||
|
|
||||||
ret.push(file);
|
ret.push(file);
|
||||||
if (file.blocks.length > 0 &&
|
if (file.blocks.length > 0 &&
|
||||||
utils.startsWith(file.blocks[0].header, GIT_BINNARY_HEADER) &&
|
utils.startsWith(file.blocks[0].header, GIT_BINARY_HEADER) &&
|
||||||
nextFile.blocks.length > 0 &&
|
nextFile.blocks.length > 0 &&
|
||||||
utils.startsWith(nextFile.blocks[0].header, PROPERTY_CHANGE_HEADER) &&
|
utils.startsWith(nextFile.blocks[0].header, PROPERTY_CHANGE_HEADER) &&
|
||||||
file.name === nextFile.name &&
|
file.name === nextFile.name &&
|
||||||
|
|
|
||||||
|
|
@ -728,5 +728,45 @@ describe('DiffParser', function() {
|
||||||
assert.deepEqual(linesContent,
|
assert.deepEqual(linesContent,
|
||||||
[' function foo() {', '-var bar = "Whoops!";', '+var baz = "Whoops!";', ' }', ' ']);
|
[' function foo() {', '-var bar = "Whoops!";', '+var baz = "Whoops!";', ' }', ' ']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse `svn diff --git` content', function() {
|
||||||
|
var diff =
|
||||||
|
'Index: color_doc.docx\n' +
|
||||||
|
'===================================================================\n' +
|
||||||
|
'diff --git a/color_doc.docx b/color_doc.docx\n' +
|
||||||
|
'new file mode 10644\n' +
|
||||||
|
'GIT binary patch\n' +
|
||||||
|
'literal 296291\n' +
|
||||||
|
'zc%1CHV|b>|mmvJaPteH|b!;ac+w9n8$F^;E+_5|E*jC3@$F^-JoBsW0W@mS2->>`O\n' +
|
||||||
|
' \n' +
|
||||||
|
'literal 0\n' +
|
||||||
|
'Hc$@<O00001\n' +
|
||||||
|
' \n' +
|
||||||
|
'Index: color_doc.docx\n' +
|
||||||
|
'===================================================================\n' +
|
||||||
|
'diff --git a/color_doc.docx b/color_doc.docx\n' +
|
||||||
|
'--- a/color_doc.docx (nonexistent)\n' +
|
||||||
|
'+++ b/color_doc.docx (revision 10)\n' +
|
||||||
|
'\n' +
|
||||||
|
'Property changes on: color_doc.docx\n' +
|
||||||
|
'___________________________________________________________________\n' +
|
||||||
|
'Added: svn:executable\n' +
|
||||||
|
'## -0,0 +1 ##\n' +
|
||||||
|
'+*\n' +
|
||||||
|
'\\ No newline at end of property\n' +
|
||||||
|
'Added: svn:mime-type\n' +
|
||||||
|
'## -0,0 +1 ##\n' +
|
||||||
|
'+application/octet-stream\n' +
|
||||||
|
'\\ No newline at end of property\n' +
|
||||||
|
' ';
|
||||||
|
var result = DiffParser.generateDiffJson(diff, {ignoreSvnPropertyChange: true});
|
||||||
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
|
var file1 = result[0];
|
||||||
|
assert.equal('color_doc.docx', file1.oldName);
|
||||||
|
assert.equal('color_doc.docx', file1.newName);
|
||||||
|
assert.equal(true, file1.isNew);
|
||||||
|
assert.equal('10644', file1.newFileMode);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue