Commit b346a97c authored by John Haley's avatar John Haley

Add `Repository.prototype.fetchheadForeach` and tests

parent 1dc26c68
......@@ -371,9 +371,9 @@
],
"return": {
"type": "int",
"noResults": 1,
"noResults": 0,
"success": 0,
"error": -1
"error": 1
}
},
"git_repository_mergehead_foreach_cb": {
......@@ -389,9 +389,9 @@
],
"return": {
"type": "int",
"noResults": 1,
"noResults": 0,
"success": 0,
"error": -1
"error": 1
}
},
"git_revwalk_hide_cb": {
......
......@@ -1456,7 +1456,10 @@
"ignore": true
},
"git_repository_fetchhead_foreach": {
"ignore": true
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_repository_hashfile": {
"ignore": true
......
......@@ -843,4 +843,14 @@ Repository.prototype.checkoutBranch = function(branch, opts) {
});
};
var fetchheadForeach = Repository.prototype.fetchheadForeach;
/**
* @async
* @param {FetchheadForeachCb} callback The callback function to be called on
* each entry
*/
Repository.prototype.fetchheadForeach = function(callback) {
return fetchheadForeach.call(this, callback, null);
};
module.exports = Repository;
......@@ -55,7 +55,9 @@ beforeEach(function() {
afterEach(function(done) {
process.nextTick(function() {
global.gc();
if (global.gc) {
global.gc();
}
done();
});
});
......@@ -137,4 +137,36 @@ describe("Repository", function() {
});
});
});
it("gets fetch-heads", function() {
var repo = this.repository;
var foundMaster;
return repo.fetch("origin", {
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
},
certificateCheck: function() {
return 1;
}
})
.then(function() {
return repo.fetchheadForeach(function(refname, remoteUrl, oid, isMerge) {
if (refname == "refs/heads/master") {
foundMaster = true;
assert.equal(refname, "refs/heads/master");
assert.equal(remoteUrl, "https://github.com/nodegit/test");
assert.equal(
oid.toString(),
"32789a79e71fbc9e04d3eff7425e1771eb595150");
assert.equal(isMerge, 1);
}
});
})
.then(function() {
if (!foundMaster) {
throw new Error("Couldn't find master in iteration of fetch heads");
}
});
});
});
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