fix eslint issues.

This commit is contained in:
Raghu Rajagopalan
2016-04-25 12:38:48 +05:30
parent 0538048f24
commit 6032e05581
3 changed files with 112 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
var Logger = require('../../logger'); var Logger = require('../../logger');
var _ = require("lodash"); var _ = require('lodash');
//var log = new Logger.Log(); //var log = new Logger.Log();
var log = new Logger.Log(1); var log = new Logger.Log(1);
@@ -7,16 +7,16 @@ var log = new Logger.Log(1);
var commits = {}; var commits = {};
var head = null; var head = null;
var branches = { "master" : head }; var branches = { 'master' : head };
var curBranch = "master"; var curBranch = 'master';
var direction = "LR"; var direction = 'LR';
var seq = 0; var seq = 0;
function getRandomInt(min, max) { function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min; return Math.floor(Math.random() * (max - min)) + min;
} }
function getId() { function getId() {
var pool="0123456789abcdef"; var pool='0123456789abcdef';
var id = ""; var id = '';
for (var i = 0; i < 7; i++) { for (var i = 0; i < 7; i++) {
id += pool[getRandomInt(0,16)] id += pool[getRandomInt(0,16)]
} }
@@ -25,12 +25,12 @@ function getId() {
function isfastforwardable(currentCommit, otherCommit) { function isfastforwardable(currentCommit, otherCommit) {
log.debug("Entering isfastforwardable:", currentCommit.id, otherCommit.id); log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id);
while (currentCommit.seq <= otherCommit.seq && currentCommit != otherCommit) { while (currentCommit.seq <= otherCommit.seq && currentCommit != otherCommit) {
// only if other branch has more commits // only if other branch has more commits
if (otherCommit.parent == null) break; if (otherCommit.parent == null) break;
if (Array.isArray(otherCommit.parent)){ if (Array.isArray(otherCommit.parent)){
log.debug("In merge commit:", otherCommit.parent); log.debug('In merge commit:', otherCommit.parent);
return isfastforwardable(currentCommit, commits[otherCommit.parent[0]]) || return isfastforwardable(currentCommit, commits[otherCommit.parent[0]]) ||
isfastforwardable(currentCommit, commits[otherCommit.parent[1]]) isfastforwardable(currentCommit, commits[otherCommit.parent[1]])
} else { } else {
@@ -53,13 +53,13 @@ exports.setDirection = function(dir) {
} }
var options = {}; var options = {};
exports.setOptions = function(rawOptString) { exports.setOptions = function(rawOptString) {
log.debug("options str", rawOptString); log.debug('options str', rawOptString);
rawOptString = rawOptString && rawOptString.trim(); rawOptString = rawOptString && rawOptString.trim();
rawOptString = rawOptString || "{}"; rawOptString = rawOptString || '{}';
try { try {
options = JSON.parse(rawOptString) options = JSON.parse(rawOptString)
} catch(e) { } catch(e) {
log.error("error while parsing gitGraph options", e.message); log.error('error while parsing gitGraph options', e.message);
} }
} }
@@ -75,19 +75,19 @@ exports.commit = function(msg) {
head = commit; head = commit;
commits[commit.id] = commit; commits[commit.id] = commit;
branches[curBranch] = commit.id; branches[curBranch] = commit.id;
log.debug("in pushCommit '" + commit.id + "'"); log.debug('in pushCommit ' + commit.id);
} }
exports.branch = function(name) { exports.branch = function(name) {
branches[name] = head != null ? head.id: null; branches[name] = head != null ? head.id: null;
log.debug("in createBranch"); log.debug('in createBranch');
} }
exports.merge = function(otherBranch) { exports.merge = function(otherBranch) {
var currentCommit = commits[branches[curBranch]]; var currentCommit = commits[branches[curBranch]];
var otherCommit = commits[branches[otherBranch]]; var otherCommit = commits[branches[otherBranch]];
if (isReachableFrom(currentCommit, otherCommit)) { if (isReachableFrom(currentCommit, otherCommit)) {
log.debug("Already merged"); log.debug('Already merged');
return; return;
} }
if (isfastforwardable(currentCommit, otherCommit)){ if (isfastforwardable(currentCommit, otherCommit)){
@@ -106,18 +106,18 @@ exports.merge = function(otherBranch) {
branches[curBranch] = commit.id; branches[curBranch] = commit.id;
} }
log.debug(branches); log.debug(branches);
log.debug("in mergeBranch"); log.debug('in mergeBranch');
} }
exports.checkout = function(branch) { exports.checkout = function(branch) {
log.debug("in checkout"); log.debug('in checkout');
curBranch = branch; curBranch = branch;
var id = branches[curBranch]; var id = branches[curBranch];
head = commits[id]; head = commits[id];
} }
exports.reset = function(ref) { exports.reset = function(ref) {
log.debug("in reset"); log.debug('in reset');
var commit = ref == 'HEAD' ? head : commits[branches[ref]]; var commit = ref == 'HEAD' ? head : commits[branches[ref]];
head = commit; head = commit;
branches[curBranch] = commit.id; branches[curBranch] = commit.id;
@@ -131,15 +131,16 @@ function upsert(arr, key, newval) {
arr.push(newval); arr.push(newval);
} }
//console.log(arr); //console.log(arr);
}; }
function prettyPrintCommitHistory(commitArr) { function prettyPrintCommitHistory(commitArr) {
var commit = _.maxBy(commitArr, 'seq'); var commit = _.maxBy(commitArr, 'seq');
var line = ""; var line = '';
_.each(commitArr, function(c, idx) { _.each(commitArr, function(c, idx) {
if (c == commit) { if (c == commit) {
line += "\t*" line += '\t*'
} else { } else {
line +="\t|" line +='\t|'
} }
}); });
var label = [line, commit.id, commit.seq]; var label = [line, commit.id, commit.seq];
@@ -172,13 +173,13 @@ exports.prettyPrint = function() {
exports.clear = function () { exports.clear = function () {
commits = {}; commits = {};
head = null; head = null;
branches = { "master" : head }; branches = { 'master' : head };
curBranch = "master"; curBranch = 'master';
seq =0; seq =0;
} }
exports.getBranchesAsObjArray = function() { exports.getBranchesAsObjArray = function() {
return _.map(branches, function(v,k) { return _.map(branches, function(v,k) {
return {"name": k, "commit": commits[v]}; return {'name': k, 'commit': commits[v]};
}); });
} }
exports.getBranches = function() { return branches; } exports.getBranches = function() { return branches; }

View File

@@ -1,7 +1,7 @@
var parser = require('./parser/gitGraph').parser; var parser = require('./parser/gitGraph').parser;
var ast = require("./gitGraphAst.js"); var ast = require('./gitGraphAst.js');
describe('when parsing a gitGraph',function() { describe('when parsing a gitGraph',function() {
"use strict"; 'use strict';
beforeEach(function () { beforeEach(function () {
parser.yy = ast; parser.yy = ast;
parser.yy.clear(); parser.yy.clear();
@@ -15,8 +15,8 @@ describe('when parsing a gitGraph',function() {
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getDirection()).toBe("LR"); expect(parser.yy.getDirection()).toBe('LR');
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
}); });
@@ -32,8 +32,8 @@ describe('when parsing a gitGraph',function() {
expect(parser.yy.getOptions()).toEqual({}); expect(parser.yy.getOptions()).toEqual({});
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getDirection()).toBe("LR"); expect(parser.yy.getDirection()).toBe('LR');
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
}); });
@@ -47,11 +47,11 @@ describe('when parsing a gitGraph',function() {
parser.parse(str); parser.parse(str);
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
console.log("options object", parser.yy.getOptions()); console.log('options object', parser.yy.getOptions());
expect(parser.yy.getOptions()["key"]).toBe("value"); expect(parser.yy.getOptions()['key']).toBe('value');
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getDirection()).toBe("LR"); expect(parser.yy.getDirection()).toBe('LR');
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
}); });
@@ -66,8 +66,8 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getDirection()).toBe("LR"); expect(parser.yy.getDirection()).toBe('LR');
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
}); });
@@ -80,8 +80,8 @@ describe('when parsing a gitGraph',function() {
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getDirection()).toBe("TB"); expect(parser.yy.getDirection()).toBe('TB');
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
}); });
@@ -94,7 +94,7 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
expect(Object.keys(commits).length).toBe(0); expect(Object.keys(commits).length).toBe(0);
expect(parser.yy.getCurrentBranch()).toBe("new"); expect(parser.yy.getCurrentBranch()).toBe('new');
}); });
it('should add commits to checked out branch', function () { it('should add commits to checked out branch', function () {
@@ -108,7 +108,7 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
expect(Object.keys(commits).length).toBe(2); expect(Object.keys(commits).length).toBe(2);
expect(parser.yy.getCurrentBranch()).toBe("new"); expect(parser.yy.getCurrentBranch()).toBe('new');
var branchCommit = parser.yy.getBranches()['new']; var branchCommit = parser.yy.getBranches()['new'];
expect(branchCommit).not.toBeNull(); expect(branchCommit).not.toBeNull();
expect(commits[branchCommit].parent).not.toBeNull(); expect(commits[branchCommit].parent).not.toBeNull();
@@ -123,8 +123,8 @@ describe('when parsing a gitGraph',function() {
expect(Object.keys(commits).length).toBe(1); expect(Object.keys(commits).length).toBe(1);
var key = Object.keys(commits)[0]; var key = Object.keys(commits)[0];
expect(commits[key].message).toBe("a commit"); expect(commits[key].message).toBe('a commit');
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
}); });
it('it should reset a branch', function () { it('it should reset a branch', function () {
@@ -140,9 +140,9 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
expect(Object.keys(commits).length).toBe(3); expect(Object.keys(commits).length).toBe(3);
expect(parser.yy.getCurrentBranch()).toBe("newbranch"); expect(parser.yy.getCurrentBranch()).toBe('newbranch');
expect(parser.yy.getBranches()["newbranch"]).toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']);
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()["newbranch"]); expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']);
}); });
it('it should handle fast forwardable merges', function () { it('it should handle fast forwardable merges', function () {
@@ -160,9 +160,9 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(3); expect(Object.keys(commits).length).toBe(3);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getBranches()["newbranch"]).toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']);
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()["newbranch"]); expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']);
}); });
it('it should handle cases when merge is a noop', function () { it('it should handle cases when merge is a noop', function () {
@@ -179,9 +179,9 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(3); expect(Object.keys(commits).length).toBe(3);
expect(parser.yy.getCurrentBranch()).toBe("newbranch"); expect(parser.yy.getCurrentBranch()).toBe('newbranch');
expect(parser.yy.getBranches()["newbranch"]).not.toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']);
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()["newbranch"]); expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']);
}); });
it('it should handle merge with 2 parents', function () { it('it should handle merge with 2 parents', function () {
@@ -200,9 +200,9 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(5); expect(Object.keys(commits).length).toBe(5);
expect(parser.yy.getCurrentBranch()).toBe("master"); expect(parser.yy.getCurrentBranch()).toBe('master');
expect(parser.yy.getBranches()["newbranch"]).not.toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']);
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']);
}); });
it('it should handle ff merge when history walk has two parents (merge commit)', function () { it('it should handle ff merge when history walk has two parents (merge commit)', function () {
@@ -224,9 +224,9 @@ describe('when parsing a gitGraph',function() {
var commits = parser.yy.getCommits(); var commits = parser.yy.getCommits();
//console.log(commits); //console.log(commits);
expect(Object.keys(commits).length).toBe(6); expect(Object.keys(commits).length).toBe(6);
expect(parser.yy.getCurrentBranch()).toBe("newbranch"); expect(parser.yy.getCurrentBranch()).toBe('newbranch');
expect(parser.yy.getBranches()["newbranch"]).toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']);
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()["master"]); expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']);
parser.yy.prettyPrint(); parser.yy.prettyPrint();
}); });

View File

@@ -11,7 +11,7 @@ var config = {
nodeWidth: 75, nodeWidth: 75,
lineStrokeWidth: 4, lineStrokeWidth: 4,
branchLineHeight: 50, branchLineHeight: 50,
lineColor: "grey", lineColor: 'grey',
leftMargin: 50, leftMargin: 50,
nodeLabel: { nodeLabel: {
width: 50, width: 50,
@@ -28,28 +28,28 @@ exports.setConf = function(c) {
function svgCreateDefs(svg) { function svgCreateDefs(svg) {
svg svg
.append("defs") .append('defs')
.append("g") .append('g')
.attr("id", "def-commit") .attr('id', 'def-commit')
.append("circle") .append('circle')
.attr("r", 15) .attr('r', 15)
.attr("cx", 0) .attr('cx', 0)
.attr("cy", 0); .attr('cy', 0);
svg.select("#def-commit") svg.select('#def-commit')
.append('foreignObject') .append('foreignObject')
.attr('width', config.nodeLabel.width) .attr('width', config.nodeLabel.width)
.attr('height', config.nodeLabel.height) .attr('height', config.nodeLabel.height)
.attr('x', config.nodeLabel.x) .attr('x', config.nodeLabel.x)
.attr('y', config.nodeLabel.y) .attr('y', config.nodeLabel.y)
.attr('class', "node-label") .attr('class', 'node-label')
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') .attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility')
.append('xhtml:p') .append('xhtml:p')
.html("a big chunk of text that should wrap"); .html('a big chunk of text that should wrap');
} }
function svgDrawLine(svg, points, interpolate) { function svgDrawLine(svg, points, interpolate) {
interpolate = interpolate || "basis"; interpolate = interpolate || 'basis';
var lineGen = d3.svg.line() var lineGen = d3.svg.line()
.x(function(d) { .x(function(d) {
return Math.round(d.x) return Math.round(d.x)
@@ -60,11 +60,11 @@ function svgDrawLine(svg, points, interpolate) {
.interpolate(interpolate); .interpolate(interpolate);
svg svg
.append("svg:path") .append('svg:path')
.attr("d", lineGen(points)) .attr('d', lineGen(points))
.style("stroke", config.lineColor) .style('stroke', config.lineColor)
.style("stroke-width", config.lineStrokeWidth) .style('stroke-width', config.lineStrokeWidth)
.style("fill", "none"); .style('fill', 'none');
} }
// Pass in the element and its pre-transform coords // Pass in the element and its pre-transform coords
function getElementCoords(element, coords) { function getElementCoords(element, coords) {
@@ -79,17 +79,17 @@ function getElementCoords(element, coords) {
width: coords.width, width: coords.width,
height: coords.height height: coords.height
}; };
}; }
function svgDrawLineForCommits(svg, fromId, toId) { function svgDrawLineForCommits(svg, fromId, toId) {
log.debug("svgDrawLineForCommits: ", fromId, toId); log.debug('svgDrawLineForCommits: ', fromId, toId);
var fromBbox = getElementCoords(svg.select("#node-" + fromId + " circle")); var fromBbox = getElementCoords(svg.select('#node-' + fromId + ' circle'));
var toBbox = getElementCoords(svg.select("#node-" + toId + " circle")); var toBbox = getElementCoords(svg.select('#node-' + toId + ' circle'));
//log.debug("svgDrawLineForCommits: ", fromBbox, toBbox); //log.debug('svgDrawLineForCommits: ', fromBbox, toBbox);
if (fromBbox.left - toBbox.left > config.nodeWidth) { if (fromBbox.left - toBbox.left > config.nodeWidth) {
var lineStart = { x: fromBbox.left - config.nodeWidth, y: toBbox.top + toBbox.height/2}; var lineStart = { x: fromBbox.left - config.nodeWidth, y: toBbox.top + toBbox.height/2};
var lineEnd ={ x: toBbox.left + toBbox.width, y: toBbox.top + toBbox.height/2 }; var lineEnd ={ x: toBbox.left + toBbox.width, y: toBbox.top + toBbox.height/2 };
svgDrawLine(svg, [lineStart , lineEnd], "linear") svgDrawLine(svg, [lineStart , lineEnd], 'linear')
svgDrawLine(svg, [ svgDrawLine(svg, [
{x: fromBbox.left, y: fromBbox.top + fromBbox.height/2}, {x: fromBbox.left, y: fromBbox.top + fromBbox.height/2},
{x: fromBbox.left - config.nodeWidth/2, y: fromBbox.top + fromBbox.height/2}, {x: fromBbox.left - config.nodeWidth/2, y: fromBbox.top + fromBbox.height/2},
@@ -97,17 +97,17 @@ function svgDrawLineForCommits(svg, fromId, toId) {
lineStart]); lineStart]);
} else { } else {
svgDrawLine(svg, [{ svgDrawLine(svg, [{
"x": fromBbox.left, 'x': fromBbox.left,
"y": fromBbox.top + fromBbox.height / 2 'y': fromBbox.top + fromBbox.height / 2
}, { }, {
"x": fromBbox.left - config.nodeWidth/2, 'x': fromBbox.left - config.nodeWidth/2,
"y": fromBbox.top + fromBbox.height / 2 'y': fromBbox.top + fromBbox.height / 2
}, { }, {
"x": fromBbox.left - config.nodeWidth/2, 'x': fromBbox.left - config.nodeWidth/2,
"y": toBbox.top + toBbox.height / 2 'y': toBbox.top + toBbox.height / 2
}, { }, {
"x": toBbox.left + toBbox.width, 'x': toBbox.left + toBbox.width,
"y": toBbox.top + toBbox.height / 2 'y': toBbox.top + toBbox.height / 2
}]); }]);
} }
} }
@@ -121,36 +121,36 @@ function renderCommitHistory(svg, commitid, branches, direction) {
if (_.isString(commitid)) { if (_.isString(commitid)) {
do { do {
commit = allCommitsDict[commitid]; commit = allCommitsDict[commitid];
log.debug("in renderCommitHistory", commit.id, commit.seq); log.debug('in renderCommitHistory', commit.id, commit.seq);
if (svg.select("#node-" + commitid).size() > 0) { if (svg.select('#node-' + commitid).size() > 0) {
return; return;
} }
svg svg
.append(function() { .append(function() {
return cloneNode(svg, "#def-commit"); return cloneNode(svg, '#def-commit');
}) })
.attr("class", "commit") .attr('class', 'commit')
.attr("id", function() { .attr('id', function() {
return "node-" + commit.id; return 'node-' + commit.id;
}) })
.attr("transform", function() { .attr('transform', function() {
return "translate(" + (commit.seq * config.nodeWidth + config.leftMargin) + ", " return 'translate(' + (commit.seq * config.nodeWidth + config.leftMargin) + ', '
+ (branchNum * config.branchLineHeight) + ")"; + (branchNum * config.branchLineHeight) + ')';
}) })
.attr("fill", "yellow") .attr('fill', 'yellow')
.attr("stroke", "grey") .attr('stroke', 'grey')
.attr("stroke-width", "2"); .attr('stroke-width', '2');
svg.select("#node-" + commit.id + " p") svg.select('#node-' + commit.id + ' p')
.text(commit.id); .text(commit.id);
var branch = _.find(branches, ["commit", commit]); var branch = _.find(branches, ['commit', commit]);
if (branch) { if (branch) {
log.debug("found branch ", branch.name); log.debug('found branch ', branch.name);
// don't try to select foreignObject - doesn't work. // don't try to select foreignObject - doesn't work.
// instead select by class name and it works. // instead select by class name and it works.
svg.select("#node-" + commit.id + " .node-label") svg.select('#node-' + commit.id + ' .node-label')
.append("xhtml:p") .append('xhtml:p')
.attr("class", "branch-label") .attr('class', 'branch-label')
.text(branch.name); .text(branch.name);
} }
commitid = commit.parent commitid = commit.parent
@@ -158,7 +158,7 @@ function renderCommitHistory(svg, commitid, branches, direction) {
} }
if (_.isArray(commitid)) { if (_.isArray(commitid)) {
log.debug("found merge commmit", commitid); log.debug('found merge commmit', commitid);
renderCommitHistory(svg, commitid[0], branches, direction); renderCommitHistory(svg, commitid[0], branches, direction);
branchNum++; branchNum++;
renderCommitHistory(svg, commitid[1], branches, direction); renderCommitHistory(svg, commitid[1], branches, direction);
@@ -187,17 +187,17 @@ exports.draw = function(txt, id, ver) {
log.debug('in gitgraph renderer', txt, id, ver); log.debug('in gitgraph renderer', txt, id, ver);
// Parse the graph definition // Parse the graph definition
parser.parse(txt + "\n"); parser.parse(txt + '\n');
config = _.extend(config, apiConfig, db.getOptions()); config = _.extend(config, apiConfig, db.getOptions());
log.debug("effective options", config); log.debug('effective options', config);
var direction = db.getDirection(); var direction = db.getDirection();
allCommitsDict = db.getCommits(); allCommitsDict = db.getCommits();
var branches = db.getBranchesAsObjArray(); var branches = db.getBranchesAsObjArray();
var svg = d3.select('#' + id); var svg = d3.select('#' + id);
svgCreateDefs(svg); svgCreateDefs(svg);
branchNum = 1; branchNum = 1;
_.each(branches, function(v, k) { _.each(branches, function(v) {
renderCommitHistory(svg, v.commit.id, branches, direction); renderCommitHistory(svg, v.commit.id, branches, direction);
renderLines(svg, v.commit); renderLines(svg, v.commit);
branchNum++; branchNum++;
@@ -206,7 +206,7 @@ exports.draw = function(txt, id, ver) {
svg.attr('height', 900); svg.attr('height', 900);
svg.attr('width', 2500); svg.attr('width', 2500);
} catch (e) { } catch (e) {
log.error("Error while rendering gitgraph"); log.error('Error while rendering gitgraph');
log.error(e.message); log.error(e.message);
} }
}; };