diff --git a/sitegin/config.js b/sitegin/config.js index a6417e92a9c41946e0186010a527b3c9f20a0ca1..5d13a5acec63960b9dea5365f1e3567d1663abac 100644 --- a/sitegin/config.js +++ b/sitegin/config.js @@ -18,7 +18,9 @@ var options = cli.parse({ contentdir: [null, 'Allows to specify arbitrary content directory.', 'string', 'content'], themedir: [null, 'Allows to specify arbitrary content directory.', 'string', 'theme'], builddir: [null, 'Allows to specify arbitrary content directory.', 'string', null], - staticdir: [null, 'Allows to specify arbitrary directory for static files.', 'string', 'static'] + staticdir: [null, 'Allows to specify arbitrary directory for static files.', 'string', 'static'], + debugarticle: [null, 'Article for which extra information should be printed out. Full file path '+ + 'relative to contentdir (Ex. articles/2010/hello-word.md)','string', null] }); module.exports = function() { diff --git a/sitegin/gitInfo.js b/sitegin/gitInfo.js index f189e6b531047c5b5c3a54fa64e194e2e5b8751e..7920c33ad836dca295b89a56aaac9604b7370232 100644 --- a/sitegin/gitInfo.js +++ b/sitegin/gitInfo.js @@ -113,6 +113,17 @@ var getFilesHistory = function(repo, startCommitMessage) { }); return filehistory; }) + .then(function(log) { + var sorter = function (a, b) { + var rhs = a.date; + var lhs = b.date; + return lhs > rhs ? 1 : lhs < rhs ? -1 : 0; + }; + for(var file in log) { + log[file].sort(sorter); + } + return log; + }) .then(function(log) { if(startCommitMessage === undefined) return log; function mergeCommit(commits) { @@ -124,6 +135,7 @@ var getFilesHistory = function(repo, startCommitMessage) { if(commit.message.indexOf(matcher) > -1) r = commit; }) }) + commits.reverse(); return r; } for(var file in log) { @@ -144,6 +156,17 @@ module.exports = function(obj) { .then(function(repo) { return getFilesHistory(repo, obj.config.git.mergeMessage); }) + .then(function(hist) { + if(obj.config.options.debugarticle !== null) { + var log = hist[obj.config.options.debugarticle]; + log.forEach(function(commit) { + console.log(' '+commit.date+' '+commit.author.email+'\t'+commit.message.replace(/\n([^]*)$/,'')); + }) + console.log() + console.log(' Starting commit: '+log.mergeCommit.message.replace(/\n([^]*)$/,'')) + } + return hist; + }) .then((filesHistory) => { obj.pages.forEach(function(article) { var file = path.relative(pathToRepo, article.filename);