Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions generate/input/callbacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@
],
"return": {
"type": "int",
"noResults": 1,
"noResults": 0,
"success": 0,
"error": -1
"error": 1
}
},
"git_repository_mergehead_foreach_cb": {
Expand All @@ -389,9 +389,9 @@
],
"return": {
"type": "int",
"noResults": 1,
"noResults": 0,
"success": 0,
"error": -1
"error": 1
}
},
"git_revwalk_hide_cb": {
Expand Down
5 changes: 4 additions & 1 deletion generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,10 @@
"ignore": true
},
"git_repository_fetchhead_foreach": {
"ignore": true
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_repository_hashfile": {
"ignore": true
Expand Down
10 changes: 10 additions & 0 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 3 additions & 1 deletion test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ beforeEach(function() {

afterEach(function(done) {
process.nextTick(function() {
global.gc();
if (global.gc) {
global.gc();
}
done();
});
});
32 changes: 32 additions & 0 deletions test/tests/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
});
});
});