◐ Shell
clean mode source ↗

Change how getReferenceCommit() retrieves commits by rcjsuen · Pull Request #1420 · nodegit/nodegit

The current code in repository.js assumes that the return value from reference.target() is an oid that points to a commit.

Repository.prototype.getReferenceCommit = function(name, callback) {
var repository = this;
return this.getReference(name).then(function(reference) {
return repository.getCommit(reference.target()).then(function(commit) {
if (typeof callback === "function") {
callback(null, commit);
}
return commit;
});
}, callback);
};

However, this is not true for annotated commits as its target oid is actually the tag object itself. To get around this, reference.peel(NodeGit.Object.TYPE.COMMIT) should be used instead so that the reference object will fully unwrap itself to the underlying commit object. This should fix #1370.