FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add `Repository.prototype.fetchheadForeach` and tests by johnhaley81 · Pull Request #514 · nodegit/nodegit · GitHub

Repository navigation

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

Filter by extension

Filter by extension .js  (3) .json  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 4 additions & 4 deletions generate/input/callbacks.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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");
}
});
});
});

Back | FazBrowse Home | New Git URL