Release version 2.0.3
This commit is contained in:
parent
8cf734d016
commit
5303b2ff24
4 changed files with 55 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"homepage": "https://diff2html.xyz",
|
"homepage": "https://diff2html.xyz",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
65
dist/diff2html.js
vendored
65
dist/diff2html.js
vendored
|
|
@ -2415,26 +2415,26 @@ process.umask = function() { return 0; };
|
||||||
var hunkHeaderPrefix = '@@';
|
var hunkHeaderPrefix = '@@';
|
||||||
|
|
||||||
/* Add previous block(if exists) before start a new file */
|
/* Add previous block(if exists) before start a new file */
|
||||||
var saveBlock = function() {
|
function saveBlock() {
|
||||||
if (currentBlock) {
|
if (currentBlock) {
|
||||||
currentFile.blocks.push(currentBlock);
|
currentFile.blocks.push(currentBlock);
|
||||||
currentBlock = null;
|
currentBlock = null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add previous file(if exists) before start a new one
|
* Add previous file(if exists) before start a new one
|
||||||
* if it has name (to avoid binary files errors)
|
* if it has name (to avoid binary files errors)
|
||||||
*/
|
*/
|
||||||
var saveFile = function() {
|
function saveFile() {
|
||||||
if (currentFile && currentFile.newName) {
|
if (currentFile && currentFile.newName) {
|
||||||
files.push(currentFile);
|
files.push(currentFile);
|
||||||
currentFile = null;
|
currentFile = null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Create file structure */
|
/* Create file structure */
|
||||||
var startFile = function() {
|
function startFile() {
|
||||||
saveBlock();
|
saveBlock();
|
||||||
saveFile();
|
saveFile();
|
||||||
|
|
||||||
|
|
@ -2442,9 +2442,9 @@ process.umask = function() { return 0; };
|
||||||
currentFile.blocks = [];
|
currentFile.blocks = [];
|
||||||
currentFile.deletedLines = 0;
|
currentFile.deletedLines = 0;
|
||||||
currentFile.addedLines = 0;
|
currentFile.addedLines = 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
var startBlock = function(line) {
|
function startBlock(line) {
|
||||||
saveBlock();
|
saveBlock();
|
||||||
|
|
||||||
var values;
|
var values;
|
||||||
|
|
@ -2489,9 +2489,9 @@ process.umask = function() { return 0; };
|
||||||
currentBlock.oldStartLine2 = oldLine2;
|
currentBlock.oldStartLine2 = oldLine2;
|
||||||
currentBlock.newStartLine = newLine;
|
currentBlock.newStartLine = newLine;
|
||||||
currentBlock.header = line;
|
currentBlock.header = line;
|
||||||
};
|
}
|
||||||
|
|
||||||
var createLine = function(line) {
|
function createLine(line) {
|
||||||
var currentLine = {};
|
var currentLine = {};
|
||||||
currentLine.content = line;
|
currentLine.content = line;
|
||||||
|
|
||||||
|
|
@ -2522,7 +2522,34 @@ process.umask = function() { return 0; };
|
||||||
|
|
||||||
currentBlock.lines.push(currentLine);
|
currentBlock.lines.push(currentLine);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if there is a hunk header coming before a new file starts
|
||||||
|
*
|
||||||
|
* Hunk header is a group of three lines started by ( `--- ` , `+++ ` , `@@` )
|
||||||
|
*/
|
||||||
|
function existHunkHeader(line, lineIdx) {
|
||||||
|
var idx = lineIdx;
|
||||||
|
|
||||||
|
while (idx < diffLines.length - 3) {
|
||||||
|
if (utils.startsWith(line, 'diff')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
utils.startsWith(diffLines[idx], oldFileNameHeader) &&
|
||||||
|
utils.startsWith(diffLines[idx + 1], newFileNameHeader) &&
|
||||||
|
utils.startsWith(diffLines[idx + 2], hunkHeaderPrefix)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var diffLines =
|
var diffLines =
|
||||||
diffInput.replace(/\\ No newline at end of file/g, '')
|
diffInput.replace(/\\ No newline at end of file/g, '')
|
||||||
|
|
@ -2638,6 +2665,8 @@ process.umask = function() { return 0; };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var doesNotExistHunkHeader = !existHunkHeader(line, lineIndex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Git diffs provide more information regarding files modes, renames, copies,
|
* Git diffs provide more information regarding files modes, renames, copies,
|
||||||
* commits between changes and similarity indexes
|
* commits between changes and similarity indexes
|
||||||
|
|
@ -2653,16 +2682,24 @@ process.umask = function() { return 0; };
|
||||||
currentFile.newFileMode = values[1];
|
currentFile.newFileMode = values[1];
|
||||||
currentFile.isNew = true;
|
currentFile.isNew = true;
|
||||||
} else if ((values = copyFrom.exec(line))) {
|
} else if ((values = copyFrom.exec(line))) {
|
||||||
currentFile.oldName = values[1];
|
if (doesNotExistHunkHeader) {
|
||||||
|
currentFile.oldName = values[1];
|
||||||
|
}
|
||||||
currentFile.isCopy = true;
|
currentFile.isCopy = true;
|
||||||
} else if ((values = copyTo.exec(line))) {
|
} else if ((values = copyTo.exec(line))) {
|
||||||
currentFile.newName = values[1];
|
if (doesNotExistHunkHeader) {
|
||||||
|
currentFile.newName = values[1];
|
||||||
|
}
|
||||||
currentFile.isCopy = true;
|
currentFile.isCopy = true;
|
||||||
} else if ((values = renameFrom.exec(line))) {
|
} else if ((values = renameFrom.exec(line))) {
|
||||||
currentFile.oldName = values[1];
|
if (doesNotExistHunkHeader) {
|
||||||
|
currentFile.oldName = values[1];
|
||||||
|
}
|
||||||
currentFile.isRename = true;
|
currentFile.isRename = true;
|
||||||
} else if ((values = renameTo.exec(line))) {
|
} else if ((values = renameTo.exec(line))) {
|
||||||
currentFile.newName = values[1];
|
if (doesNotExistHunkHeader) {
|
||||||
|
currentFile.newName = values[1];
|
||||||
|
}
|
||||||
currentFile.isRename = true;
|
currentFile.isRename = true;
|
||||||
} else if ((values = similarityIndex.exec(line))) {
|
} else if ((values = similarityIndex.exec(line))) {
|
||||||
currentFile.unchangedPercentage = values[1];
|
currentFile.unchangedPercentage = values[1];
|
||||||
|
|
|
||||||
4
dist/diff2html.min.js
vendored
4
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "diff2html",
|
"name": "diff2html",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"homepage": "https://diff2html.xyz",
|
"homepage": "https://diff2html.xyz",
|
||||||
"description": "Fast Diff to colorized HTML",
|
"description": "Fast Diff to colorized HTML",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue