Commit 2e3eb131 authored by Isabella Skořepová's avatar Isabella Skořepová

Take author from oldest commit not merge

parent bd143eea
Pipeline #210 passed with stages
......@@ -115,28 +115,21 @@ var getFilesHistory = function(repo, startCommitMessage) {
})
.then(function(log) {
if(startCommitMessage === undefined) return log;
var newLog = {};
function filterCommits(commits) {
var r = [];
function mergeCommit(commits) {
var r;
commits.reverse();
var matched = false;
commits.forEach(function(commit) {
if(!matched)
if(r === undefined)
startCommitMessage.forEach(function(matcher) {
if(commit.message.indexOf(matcher) > -1) matched = true;
if(commit.message.indexOf(matcher) > -1) r = commit;
})
if(matched) {
r.push(commit);
}
})
r.reverse();
if(r.length < 1) return undefined;
return r;
}
for(var file in log) {
newLog[file] = filterCommits(log[file]);
log[file].mergeCommit = mergeCommit(log[file]);
}
return newLog;
return log;
});
}
......@@ -161,12 +154,17 @@ module.exports = function(obj) {
});
var newestCommit = commits[0];
var oldestCommit = commits[commits.length-1];
var mergeCommit = commits.mergeCommit;
if(article.metadata.date === undefined)
article.metadata.date = {};
if(article.metadata.date.creation === undefined)
article.metadata.date.creation = oldestCommit.date;
if(article.metadata.date.creation === undefined) {
if(mergeCommit === undefined)
article.metadata.date.creation = moment();
else
article.metadata.date.creation = mergeCommit.date;
}
article.metadata.date.modification = newestCommit.date;
article.metadata.date.modified = (newestCommit !== oldestCommit);
......
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