Trying to access the HEAD reference using NodeGit. I am new to nodejs so this might simply be because I missed something. The following code finds the head but it always returns {}
. Not sure what I am doing wrong.
Code starts outside this file by calling getHead(res)
.
var NodeGit = require("nodegit");
var pathToRepo = require("path").resolve("C:\\Users\\Betsegaw\\Desktop\\windowwalker");
function _getHead() {
var head = new Promise(
function (resolve, reject){
NodeGit.Repository.open(pathToRepo).then(function (repo) {
return repo.head();
}).then(function (reference) {
console.log("Found head " + JSON.stringify(reference));
resolve(reference);
});
});
return head;
}
module.exports = {
getHEAD: function (res) {
_getHead().then(function(head) {
console.log(head);
res.send(head);
});
}
};
Edit: Minor typo in sample code