Skip to content

Commit c1ff5fa

Browse files
author
John Haley
committed
Added in optional ignore cert param for fetching
1 parent edf5bb2 commit c1ff5fa

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

lib/repository.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,17 @@ Repository.prototype.getRemote = function(remote, callback) {
512512
*
513513
* @param {String|Remote} remote
514514
*/
515-
Repository.prototype.fetch = function(remote, remoteCallbacks, callback) {
515+
Repository.prototype.fetch = function(
516+
remote,
517+
remoteCallbacks,
518+
ignoreCertErrors,
519+
callback)
520+
{
516521
var repo = this;
517522

518523
return repo.getRemote(remote).then(function(remote) {
519524
remote.setCallbacks(remoteCallbacks);
525+
remote.checkCert(ignoreCertErrors ? 0 : 1);
520526

521527
return remote.fetch(repo.defaultSignature(), "Fetch from " + remote)
522528
.then(function() {
@@ -530,14 +536,19 @@ Repository.prototype.fetch = function(remote, remoteCallbacks, callback) {
530536
/**
531537
* Fetches from all remotes
532538
*/
533-
Repository.prototype.fetchAll = function(remoteCallbacks, callback) {
539+
Repository.prototype.fetchAll = function(
540+
remoteCallbacks,
541+
ignoreCertErrors,
542+
callback)
543+
{
534544
var repo = this;
535545

536546
return repo.getRemotes().then(function(remotes) {
537547
var fetchPromises = [];
538548

539549
remotes.forEach(function(remote) {
540-
fetchPromises.push(repo.fetch(remote, remoteCallbacks, callback));
550+
fetchPromises.push(
551+
repo.fetch(remote, remoteCallbacks, ignoreCertErrors, callback));
541552
});
542553

543554
return Promise.all(fetchPromises);

test/tests/remote.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ describe("Remote", function() {
108108
credentials: function(url, userName) {
109109
return NodeGit.Cred.sshKeyFromAgent(userName);
110110
}
111-
});
111+
}, true);
112112
});
113+
114+
it("can fetch from all remotes", function() {
115+
return this.repository.fetchAll({
116+
credentials: function(url, userName) {
117+
return NodeGit.Cred.sshKeyFromAgent(userName);
118+
}
119+
}, true);
120+
});
121+
113122
});

0 commit comments

Comments
 (0)