Commit 4963d114 authored by Isabella Skořepová's avatar Isabella Skořepová

Replace nodegit-kit with custom code

It caused more problems than it solved

This fixes #8

Also fixed generator crashing when article was not commited
parent 7db19364
......@@ -4,7 +4,6 @@
*/
var nodegit = require('nodegit');
var git = require('nodegit-kit');
var path = require('path');
var moment = require('moment');
......@@ -45,12 +44,51 @@ var gitShow = function(repo, commitData) {
});
}
var gitlog = function(repo) {
var map = function(repo){
return Promise.resolve()
.then(function(){
return function(commit){
var author = commit.author();
var sha = commit.sha();
return {
'commit': sha,
'author': {
'name': author.name(),
'email': author.email()
},
'date': commit.date(),
'message': commit.message().trim()
};
};
});
};
return repo.getHeadCommit()
.then(function(commit) {
return new Promise(function(resolve, reject){
commit.history()
.on('end', resolve)
.on('error', reject)
.start();
})
.then(function(commits){
return map(repo)
.then(function(log){
return commits.map(log);
});
});
});
};
var getFilesHistory = function() {
var repo;
return git.open(pathToRepo)
return nodegit.Repository.open(pathToRepo)
.then(function(_repo) {
repo = _repo;
return git.log(repo)
return gitlog(repo)
})
.then(function(log){
var promises = [];
......
......@@ -40,6 +40,8 @@ module.exports = function(obj) {
obj.redirects.push(pg);
pageList.sort(function (a, b) {
if(a.metadata.date === undefined) return -1;
if(b.metadata.date === undefined) return 1;
var rhs = a.metadata.date.creation;
var lhs = b.metadata.date.creation;
return lhs > rhs ? 1 : lhs < rhs ? -1 : 0;
......
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