Commit a2bc2b71 authored by Isabella Skořepová's avatar Isabella Skořepová

Fix issues with commit ordering

Explicitly order all commits
parent 2e3eb131
Pipeline #211 passed with stages
......@@ -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() {
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment