Skip to content
Snippets Groups Projects
Verified Commit 6b1e96b3 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Creation date from 1st merge request

Configuration option (config.toml):

[git]
mergeMessage = "array or string"
parent b727cb00
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -51,7 +51,6 @@ module.exports = function() {
return resolve({config: config});
}
data = toml.parse(data);
console.log('data: '+data);
for(let attr in config) { data[attr] = config[attr]; }
resolve({config: data});
})
......
......@@ -58,7 +58,7 @@ var gitlog = function(repo) {
'email': author.email()
},
'date': commit.date(),
'message': commit.message().trim()
'message': commit.message()
};
};
});
......@@ -82,7 +82,10 @@ var gitlog = function(repo) {
});
};
var getFilesHistory = function(repo) {
var getFilesHistory = function(repo, startCommitMessage) {
if(!Array.isArray(startCommitMessage) && startCommitMessage !== undefined) {
startCommitMessage = [startCommitMessage];
}
return Promise.resolve()
.then(function() {
return gitlog(repo)
......@@ -109,6 +112,31 @@ var getFilesHistory = function(repo) {
});
});
return filehistory;
})
.then(function(log) {
if(startCommitMessage === undefined) return log;
var newLog = {};
function filterCommits(commits) {
var r = [];
commits.reverse();
var matched = false;
commits.forEach(function(commit) {
if(!matched)
startCommitMessage.forEach(function(matcher) {
if(commit.message.indexOf(matcher) > -1) matched = true;
})
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]);
}
return newLog;
});
}
......@@ -120,7 +148,9 @@ module.exports = function(obj) {
.catch(function() {
resolve(obj);
})
.then(getFilesHistory)
.then(function(repo) {
return getFilesHistory(repo, obj.config.git.mergeMessage);
})
.then((filesHistory) => {
obj.pages.forEach(function(article) {
var file = path.relative(pathToRepo, article.filename);
......@@ -149,6 +179,8 @@ module.exports = function(obj) {
article.metadata.author.email = oldestCommit.author.email
article.commits = commits;
} else {
console.log('[Warning] Article '+ file +' is not in git repository or doesn\'t have merge commit');
}
});
return obj;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment