From a2bc2b71c05dc9404765fc0e7c21edf27dabd267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= <jakub@skorepa.info> Date: Mon, 18 Apr 2016 00:02:36 +0200 Subject: [PATCH] Fix issues with commit ordering Explicitly order all commits --- sitegin/config.js | 4 +++- sitegin/gitInfo.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sitegin/config.js b/sitegin/config.js index a6417e92..5d13a5ac 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 f189e6b5..7920c33a 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); -- GitLab