Prepare for release 2.0.0-beta18

This commit is contained in:
Rodrigo Fernandes 2016-05-06 23:19:12 +01:00
parent 2b05eaf0fa
commit ef4a4e1b76
No known key found for this signature in database
GPG key ID: 08E3C5F38969078E
5 changed files with 74 additions and 21 deletions

View file

@ -13,12 +13,14 @@
[![npm](https://img.shields.io/npm/dm/diff2html.svg)](https://www.npmjs.com/package/diff2html) [![npm](https://img.shields.io/npm/dm/diff2html.svg)](https://www.npmjs.com/package/diff2html)
[![Gitter](https://badges.gitter.im/rtfpessoa/diff2html.svg)](https://gitter.im/rtfpessoa/diff2html?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/rtfpessoa/diff2html.svg)](https://gitter.im/rtfpessoa/diff2html?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
diff2html generates pretty HTML diffs from git diff output. diff2html generates pretty HTML diffs from git or unified diff output.
[![NPM](https://nodei.co/npm/diff2html.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/diff2html/) [![NPM](https://nodei.co/npm/diff2html.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/diff2html/)
## Features ## Features
* Supports git and unified diffs
* Line by line and Side by side diff * Line by line and Side by side diff
* New and old line numbers * New and old line numbers

View file

@ -1,6 +1,6 @@
{ {
"name": "diff2html", "name": "diff2html",
"version": "2.0.0-beta17", "version": "2.0.0-beta18",
"homepage": "http://rtfpessoa.github.io/diff2html/", "homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML", "description": "Fast Diff to colorized HTML",
"keywords": [ "keywords": [

76
dist/diff2html.js vendored
View file

@ -2333,32 +2333,30 @@ process.umask = function() { return 0; };
var oldLine2 = null; // Used for combined diff var oldLine2 = null; // Used for combined diff
var newLine = null; var newLine = null;
var saveBlock = function() {
/* Add previous block(if exists) before start a new file */ /* Add previous block(if exists) before start a new file */
var saveBlock = function() {
if (currentBlock) { if (currentBlock) {
currentFile.blocks.push(currentBlock); currentFile.blocks.push(currentBlock);
currentBlock = null; currentBlock = null;
} }
}; };
var saveFile = function() {
/* /*
* 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() {
if (currentFile && currentFile.newName) { if (currentFile && currentFile.newName) {
files.push(currentFile); files.push(currentFile);
currentFile = null; currentFile = null;
} }
}; };
/* Create file structure */
var startFile = function() { var startFile = function() {
saveBlock(); saveBlock();
saveFile(); saveFile();
/* Create file structure */
currentFile = {}; currentFile = {};
currentFile.blocks = []; currentFile.blocks = [];
currentFile.deletedLines = 0; currentFile.deletedLines = 0;
@ -2479,18 +2477,72 @@ process.umask = function() { return 0; };
return; return;
} }
var values = []; if (
if (utils.startsWith(line, 'diff')) { utils.startsWith(line, 'diff') || // Git diffs always start with diff
!currentFile || // If we do not have a file yet, we should crete one
(
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
)
)
) {
startFile(); startFile();
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) { }
var values;
/*
* --- 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.oldName = values;
currentFile.language = getExtension(currentFile.oldName, currentFile.language); currentFile.language = getExtension(currentFile.oldName, currentFile.language);
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) { 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.newName = values;
currentFile.language = getExtension(currentFile.newName, currentFile.language); currentFile.language = getExtension(currentFile.newName, currentFile.language);
} else if (currentFile && utils.startsWith(line, '@@')) { return;
}
if (currentFile && utils.startsWith(line, '@')) {
startBlock(line); startBlock(line);
} else if ((values = oldMode.exec(line))) { return;
}
/*
* There are three types of diff lines. These lines are defined by the way they start.
* 1. New line starts with: +
* 2. Old line starts with: -
* 3. Context line starts with: <SPACE>
*/
if (currentBlock && (utils.startsWith(line, '+') || utils.startsWith(line, '-') || utils.startsWith(line, ' '))) {
createLine(line);
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
*/
if ((values = oldMode.exec(line))) {
currentFile.oldMode = values[1]; currentFile.oldMode = values[1];
} else if ((values = newMode.exec(line))) { } else if ((values = newMode.exec(line))) {
currentFile.newMode = values[1]; currentFile.newMode = values[1];
@ -2532,8 +2584,6 @@ process.umask = function() { return 0; };
} else if ((values = combinedDeletedFile.exec(line))) { } else if ((values = combinedDeletedFile.exec(line))) {
currentFile.deletedFileMode = values[1]; currentFile.deletedFileMode = values[1];
currentFile.isDeleted = true; currentFile.isDeleted = true;
} else if (currentBlock) {
createLine(line);
} }
}); });

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "diff2html", "name": "diff2html",
"version": "2.0.0-beta17", "version": "2.0.0-beta18",
"homepage": "http://rtfpessoa.github.io/diff2html/", "homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML", "description": "Fast Diff to colorized HTML",
"keywords": [ "keywords": [