2.0.0-rc.8
This commit is contained in:
parent
8679bc354d
commit
8fe49abaa4
4 changed files with 60 additions and 39 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "diff2html",
|
||||
"version": "2.0.0-rc.7",
|
||||
"version": "2.0.0-rc.8",
|
||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||
"description": "Fast Diff to colorized HTML",
|
||||
"keywords": [
|
||||
|
|
|
|||
90
dist/diff2html.js
vendored
90
dist/diff2html.js
vendored
|
|
@ -2478,6 +2478,11 @@ var Hogan = {};
|
|||
.replace(/\r\n?/g, '\n')
|
||||
.split('\n');
|
||||
|
||||
/* Diff Header */
|
||||
var oldFileNameHeader = '--- ';
|
||||
var newFileNameHeader = '+++ ';
|
||||
var hunkHeaderPrefix = '@@';
|
||||
|
||||
/* Diff */
|
||||
var oldMode = /^old mode (\d{6})/;
|
||||
var newMode = /^new mode (\d{6})/;
|
||||
|
|
@ -2500,7 +2505,7 @@ var Hogan = {};
|
|||
var combinedNewFile = /^new file mode (\d{6})/;
|
||||
var combinedDeletedFile = /^deleted file mode (\d{6}),(\d{6})/;
|
||||
|
||||
diffLines.forEach(function(line) {
|
||||
diffLines.forEach(function(line, lineIndex) {
|
||||
// Unmerged paths, and possibly other non-diffable files
|
||||
// https://github.com/scottgonzalez/pretty-diff/issues/11
|
||||
// Also, remove some useless lines
|
||||
|
|
@ -2508,14 +2513,23 @@ var Hogan = {};
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
utils.startsWith(line, 'diff') || // Git diffs always start with diff
|
||||
!currentFile || // If we do not have a file yet, we should crete one
|
||||
var prevLine = diffLines[lineIndex - 1];
|
||||
var nxtLine = diffLines[lineIndex + 1];
|
||||
var afterNxtLine = diffLines[lineIndex + 2];
|
||||
|
||||
if (utils.startsWith(line, 'diff')) {
|
||||
startFile();
|
||||
currentFile.isGitDiff = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentFile || // If we do not have a file yet, we should crete one
|
||||
(
|
||||
currentFile && // If we already have some file in progress and
|
||||
!currentFile.isGitDiff && currentFile && // If we already have some file in progress and
|
||||
(
|
||||
currentFile.oldName && utils.startsWith(line, '--- ') || // Either we reached a old file identification line
|
||||
currentFile.newName && utils.startsWith(line, '+++ ') // Or we reached a new file identification line
|
||||
utils.startsWith(line, oldFileNameHeader) && // If we get to an old file path header line
|
||||
// And is followed by the new file path header line and the hunk header line
|
||||
utils.startsWith(nxtLine, newFileNameHeader) && utils.startsWith(afterNxtLine, hunkHeaderPrefix)
|
||||
)
|
||||
)
|
||||
) {
|
||||
|
|
@ -2525,28 +2539,43 @@ var Hogan = {};
|
|||
var values;
|
||||
|
||||
/*
|
||||
* --- Date Timestamp[FractionalSeconds] TimeZone
|
||||
* --- 2002-02-21 23:30:39.942229878 -0800
|
||||
* We need to make sure that we have the three lines of the header.
|
||||
* This avoids cases like the ones described in:
|
||||
* - https://github.com/rtfpessoa/diff2html/issues/87
|
||||
*/
|
||||
if (currentFile && !currentFile.oldName &&
|
||||
utils.startsWith(line, '--- ') && (values = getSrcFilename(line, config))) {
|
||||
currentFile.oldName = values;
|
||||
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
||||
return;
|
||||
if (
|
||||
(utils.startsWith(line, oldFileNameHeader) &&
|
||||
utils.startsWith(nxtLine, newFileNameHeader) && utils.startsWith(afterNxtLine, hunkHeaderPrefix)) ||
|
||||
|
||||
(utils.startsWith(line, newFileNameHeader) &&
|
||||
utils.startsWith(prevLine, oldFileNameHeader) && utils.startsWith(nxtLine, hunkHeaderPrefix))
|
||||
) {
|
||||
|
||||
/*
|
||||
* --- Date Timestamp[FractionalSeconds] TimeZone
|
||||
* --- 2002-02-21 23:30:39.942229878 -0800
|
||||
*/
|
||||
if (currentFile && !currentFile.oldName &&
|
||||
utils.startsWith(line, '--- ') && (values = getSrcFilename(line, config))) {
|
||||
currentFile.oldName = values;
|
||||
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* +++ Date Timestamp[FractionalSeconds] TimeZone
|
||||
* +++ 2002-02-21 23:30:39.942229878 -0800
|
||||
*/
|
||||
if (currentFile && !currentFile.newName &&
|
||||
utils.startsWith(line, '+++ ') && (values = getDstFilename(line, config))) {
|
||||
currentFile.newName = values;
|
||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* +++ Date Timestamp[FractionalSeconds] TimeZone
|
||||
* +++ 2002-02-21 23:30:39.942229878 -0800
|
||||
*/
|
||||
if (currentFile && !currentFile.newName &&
|
||||
utils.startsWith(line, '+++ ') && (values = getDstFilename(line, config))) {
|
||||
currentFile.newName = values;
|
||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentFile && utils.startsWith(line, '@')) {
|
||||
if (currentFile && utils.startsWith(line, hunkHeaderPrefix)) {
|
||||
startBlock(line);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2562,13 +2591,6 @@ var Hogan = {};
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(currentFile && currentFile.blocks.length) ||
|
||||
(currentBlock && currentBlock.lines.length)
|
||||
) {
|
||||
startFile();
|
||||
}
|
||||
|
||||
/*
|
||||
* Git diffs provide more information regarding files modes, renames, copies,
|
||||
* commits between changes and similarity indexes
|
||||
|
|
@ -3854,7 +3876,7 @@ module.exports = global.browserTemplates;
|
|||
return result;
|
||||
}
|
||||
|
||||
return str.indexOf(start) === 0;
|
||||
return str && str.indexOf(start) === 0;
|
||||
};
|
||||
|
||||
Utils.prototype.valueOrEmpty = function(value) {
|
||||
|
|
|
|||
5
dist/diff2html.min.js
vendored
5
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "diff2html",
|
||||
"version": "2.0.0-rc.7",
|
||||
"version": "2.0.0-rc.8",
|
||||
"homepage": "http://rtfpessoa.github.io/diff2html/",
|
||||
"description": "Fast Diff to colorized HTML",
|
||||
"keywords": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue