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