mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 16:29:40 +02:00
WIP - pretty print commit on console
This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
"dagre": "^0.7.4",
|
"dagre": "^0.7.4",
|
||||||
"dagre-d3": "0.4.10",
|
"dagre-d3": "0.4.10",
|
||||||
"he": "^0.5.0",
|
"he": "^0.5.0",
|
||||||
|
"lodash": "^4.6.1",
|
||||||
"minimist": "^1.1.0",
|
"minimist": "^1.1.0",
|
||||||
"mkdirp": "^0.5.0",
|
"mkdirp": "^0.5.0",
|
||||||
"moment": "^2.9.0",
|
"moment": "^2.9.0",
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
var crypto = require("crypto");
|
var crypto = require("crypto");
|
||||||
var Logger = require('../../logger');
|
var Logger = require('../../logger');
|
||||||
var log = new Logger.Log();
|
var log = new Logger.Log();
|
||||||
|
var _ = require("lodash");
|
||||||
//var log = new Logger.Log(1);
|
//var log = new Logger.Log(1);
|
||||||
|
|
||||||
|
|
||||||
@@ -42,9 +43,11 @@ function isReachableFrom(currentCommit, otherCommit) {
|
|||||||
if (currentSeq > otherSeq) return isfastforwardable(otherCommit, currentCommit);
|
if (currentSeq > otherSeq) return isfastforwardable(otherCommit, currentCommit);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.setDirection = function(dir) {
|
exports.setDirection = function(dir) {
|
||||||
direction = dir;
|
direction = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.commit = function(msg) {
|
exports.commit = function(msg) {
|
||||||
var commit = { id: getId(),
|
var commit = { id: getId(),
|
||||||
message: msg,
|
message: msg,
|
||||||
@@ -101,6 +104,14 @@ exports.reset = function(ref) {
|
|||||||
branches[curBranch] = commit.id;
|
branches[curBranch] = commit.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.prettyPrint = function() {
|
||||||
|
var commitArr = Object.keys(commits).map(function (key) {
|
||||||
|
return commits[key];
|
||||||
|
});
|
||||||
|
var sortedCommits = _.orderBy(commitArr, ['seq'], ['desc']);
|
||||||
|
console.log(sortedCommits);
|
||||||
|
}
|
||||||
|
|
||||||
exports.clear = function () {
|
exports.clear = function () {
|
||||||
commits = {};
|
commits = {};
|
||||||
head = null;
|
head = null;
|
||||||
|
@@ -176,5 +176,7 @@ describe('when parsing a gitGraph',function() {
|
|||||||
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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user