Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
5 changes: 4 additions & 1 deletion 5 generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,10 @@
"selfFreeing": true,
"functions": {
"git_remote_create": {
"isAsync": false
"isAsync": true,
"return": {
"isErrorCode": true
}
},
"git_remote_connect": {
"isAsync": true,
Expand Down
82 changes: 49 additions & 33 deletions 82 test/tests/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ describe("Remote", function() {

it("can set a remote", function() {
var repository = this.repository;
Remote.create(repository, "origin1", url);

Remote.setPushurl(repository, "origin1", "https://google.com/");

return Remote.lookup(repository, "origin1").then(function(remote) {
assert.equal(remote.pushurl(), "https://google.com/");
});
return Remote.create(repository, "origin1", url)
.then(function() {
return Remote.setPushurl(repository, "origin1", "https://google.com/");
})
.then(function() {
return Remote.lookup(repository, "origin1");
})
.then(function(remote) {
assert.equal(remote.pushurl(), "https://google.com/");
});
});

it("can read the remote name", function() {
Expand All @@ -78,22 +82,28 @@ describe("Remote", function() {

it("can create and load a new remote", function() {
var repository = this.repository;
Remote.create(repository, "origin2", url);

return Remote.lookup(repository, "origin2").then(function(remote) {
assert(remote.url(), url);
});
return Remote.create(repository, "origin2", url)
.then(function() {
return Remote.lookup(repository, "origin2");
})
.then(function(remote) {
assert(remote.url(), url);
});
});

it("can delete a remote", function() {
var repository = this.repository;
Remote.create(repository, "origin3", url);

return Remote.delete(repository, "origin3")
return Remote.create(repository, "origin3", url)
.then(function() {
return Remote.lookup(repository, "origin3");
return Remote.delete(repository, "origin3");
})
.then(Promise.reject.bind(Promise), Promise.resolve.bind(Promise));
.then(function() {
return Remote.lookup(repository, "origin3")
// We only want to catch the failed lookup
.then(Promise.reject.bind(Promise), Promise.resolve.bind(Promise));
});
});

it("can download from a remote", function() {
Expand Down Expand Up @@ -124,9 +134,7 @@ describe("Remote", function() {
var repo = this.repository;
var wasCalled = false;

Remote.create(repo, "test2", url2);

return repo.getRemote("test2")
return Remote.create(repo, "test2", url2)
.then(function(remote) {
var fetchOpts = {
callbacks: {
Expand Down Expand Up @@ -183,7 +191,6 @@ describe("Remote", function() {

it("can fetch from a private repository", function() {
var repo = this.repository;
var remote = Remote.create(repo, "private", privateUrl);
var fetchOptions = {
callbacks: {
credentials: function(url, userName) {
Expand All @@ -200,7 +207,10 @@ describe("Remote", function() {
}
};

return remote.fetch(null, fetchOptions, "Fetch from private")
return Remote.create(repo, "private", privateUrl)
.then(function(remote) {
return remote.fetch(null, fetchOptions, "Fetch from private");
})
.catch(function() {
assert.fail("Unable to fetch from private repository");
});
Expand All @@ -209,7 +219,6 @@ describe("Remote", function() {
it("can reject fetching from private repository without valid credentials",
function() {
var repo = this.repository;
var remote = Remote.create(repo, "private", privateUrl);
var firstPass = true;
var fetchOptions = {
callbacks: {
Expand All @@ -225,7 +234,10 @@ describe("Remote", function() {
}
};

return remote.fetch(null, fetchOptions, "Fetch from private")
return Remote.create(repo, "private", privateUrl)
.then(function(remote) {
return remote.fetch(null, fetchOptions, "Fetch from private");
})
.then(function () {
assert.fail("Should not be able to fetch from repository");
})
Expand All @@ -240,19 +252,23 @@ describe("Remote", function() {

it("can fetch from all remotes", function() {
var repository = this.repository;
Remote.create(repository, "test1", url);
Remote.create(repository, "test2", url2);

return repository.fetchAll({
callbacks: {
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
},
certificateCheck: function() {
return 1;
}
}
});
return Remote.create(repository, "test1", url)
.then(function() {
return Remote.create(repository, "test2", url2);
})
.then(function() {
return repository.fetchAll({
callbacks: {
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyFromAgent(userName);
},
certificateCheck: function() {
return 1;
}
}
});
});
});

it("will reject if credentials promise rejects", function() {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.