Skip to content

Commit

Permalink
Release version 2.0.0-rc.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfpessoa committed May 20, 2016
1 parent ae347be commit 15a2794
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diff2html",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML",
"keywords": [
Expand Down
16 changes: 4 additions & 12 deletions dist/diff2html.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
line-height: 18px;
margin-left: 50px;
/* Override HighlightJS */
color: inherit;
overflow-x: inherit;
background: none;
/*color: inherit;*/
/*overflow-x: inherit;*/
/*background: none;*/
/* ******************** */
}

Expand Down Expand Up @@ -215,16 +215,8 @@
border-color: #d5e4f2;
}

.d2h-del.d2h-change, .d2h-ins.d2h-change {
background-color: #ffc;
}

ins.d2h-change, del.d2h-change {
background-color: #fad771;
}

.d2h-file-diff .d2h-del.d2h-change {
background-color: #fae1af;
background-color: #fdf2d0;
}

.d2h-file-diff .d2h-ins.d2h-change {
Expand Down
65 changes: 61 additions & 4 deletions dist/diff2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,8 @@ process.umask = function() { return 0; };
var utils = require('./utils.js').Utils;
var Rematch = require('./rematch.js').Rematch;

var separator = '/';

function PrinterUtils() {
}

Expand All @@ -3144,18 +3146,65 @@ process.umask = function() { return 0; };
};

PrinterUtils.prototype.getDiffName = function(file) {
var oldFilename = file.oldName;
var newFilename = file.newName;
var oldFilename = unifyPath(file.oldName);
var newFilename = unifyPath(file.newName);

if (oldFilename && newFilename && oldFilename !== newFilename && !isDevNullName(oldFilename) && !isDevNullName(newFilename)) {
return oldFilename + ' -> ' + newFilename;
var prefixPaths = [];
var suffixPaths = [];

var oldFilenameParts = oldFilename.split(separator);
var newFilenameParts = newFilename.split(separator);

var oldFilenamePartsSize = oldFilenameParts.length;
var newFilenamePartsSize = newFilenameParts.length;

var i = 0;
var j = oldFilenamePartsSize - 1;
var k = newFilenamePartsSize - 1;

while (i < j && i < k) {
if (oldFilenameParts[i] === newFilenameParts[i]) {
prefixPaths.push(newFilenameParts[i]);
i += 1;
} else {
break;
}
}

while (j > i && k > i) {
if (oldFilenameParts[j] === newFilenameParts[k]) {
suffixPaths.unshift(newFilenameParts[k]);
j -= 1;
k -= 1;
} else {
break;
}
}

var finalPrefix = prefixPaths.join(separator);
var finalSuffix = suffixPaths.join(separator);

var oldRemainingPath = oldFilenameParts.slice(i, j + 1).join(separator);
var newRemainingPath = newFilenameParts.slice(i, k + 1).join(separator);

if (finalPrefix.length && finalSuffix.length) {
return finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix;
} else if (finalPrefix.length) {
return finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}';
} else if (finalSuffix.length) {
return '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix;
}

return oldFilename + ' → ' + newFilename;

} else if (newFilename && !isDevNullName(newFilename)) {
return newFilename;
} else if (oldFilename) {
return oldFilename;
}

return 'Unknown filename';
return 'unknown/file/path';
};

PrinterUtils.prototype.diffHighlight = function(diffLine1, diffLine2, config) {
Expand Down Expand Up @@ -3240,6 +3289,14 @@ process.umask = function() { return 0; };
};
};

function unifyPath(path) {
if (path) {
return path.replace('\\', '/');
}

return path;
}

function isDevNullName(name) {
return name.indexOf('dev/null') !== -1;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/diff2html.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/diff2html.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diff2html",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML",
"keywords": [
Expand Down

0 comments on commit 15a2794

Please sign in to comment.