| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1630,7 +1630,10 @@ | |||
| 1630 | 1630 | "selfFreeing": true, | |
| 1631 | 1631 | "functions": { | |
| 1632 | 1632 | "git_remote_create": { | |
| 1633 | - "isAsync": false | ||
| 1633 | + "isAsync": true, | ||
| 1634 | + "return": { | ||
| 1635 | + "isErrorCode": true | ||
| 1636 | + } | ||
| 1634 | 1637 | }, | |
| 1635 | 1638 | "git_remote_connect": { | |
| 1636 | 1639 | "isAsync": true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,13 +63,17 @@ describe("Remote", function() { | |||
| 63 | 63 | ||
| 64 | 64 | it("can set a remote", function() { | |
| 65 | 65 | var repository = this.repository; | |
| 66 | - Remote.create(repository, "origin1", url); | ||
| 67 | 66 | ||
| 68 | - Remote.setPushurl(repository, "origin1", "https://google.com/"); | ||
| 69 | - | ||
| 70 | - return Remote.lookup(repository, "origin1").then(function(remote) { | ||
| 71 | - assert.equal(remote.pushurl(), "https://google.com/"); | ||
| 72 | - }); | ||
| 67 | + return Remote.create(repository, "origin1", url) | ||
| 68 | + .then(function() { | ||
| 69 | + return Remote.setPushurl(repository, "origin1", "https://google.com/"); | ||
| 70 | + }) | ||
| 71 | + .then(function() { | ||
| 72 | + return Remote.lookup(repository, "origin1"); | ||
| 73 | + }) | ||
| 74 | + .then(function(remote) { | ||
| 75 | + assert.equal(remote.pushurl(), "https://google.com/"); | ||
| 76 | + }); | ||
| 73 | 77 | }); | |
| 74 | 78 | ||
| 75 | 79 | it("can read the remote name", function() { | |
@@ -78,22 +82,28 @@ describe("Remote", function() { | |||
| 78 | 82 | ||
| 79 | 83 | it("can create and load a new remote", function() { | |
| 80 | 84 | var repository = this.repository; | |
| 81 | - Remote.create(repository, "origin2", url); | ||
| 82 | 85 | ||
| 83 | - return Remote.lookup(repository, "origin2").then(function(remote) { | ||
| 84 | - assert(remote.url(), url); | ||
| 85 | - }); | ||
| 86 | + return Remote.create(repository, "origin2", url) | ||
| 87 | + .then(function() { | ||
| 88 | + return Remote.lookup(repository, "origin2"); | ||
| 89 | + }) | ||
| 90 | + .then(function(remote) { | ||
| 91 | + assert(remote.url(), url); | ||
| 92 | + }); | ||
| 86 | 93 | }); | |
| 87 | 94 | ||
| 88 | 95 | it("can delete a remote", function() { | |
| 89 | 96 | var repository = this.repository; | |
| 90 | - Remote.create(repository, "origin3", url); | ||
| 91 | 97 | ||
| 92 | - return Remote.delete(repository, "origin3") | ||
| 98 | + return Remote.create(repository, "origin3", url) | ||
| 93 | 99 | .then(function() { | |
| 94 | - return Remote.lookup(repository, "origin3"); | ||
| 100 | + return Remote.delete(repository, "origin3"); | ||
| 95 | 101 | }) | |
| 96 | - .then(Promise.reject.bind(Promise), Promise.resolve.bind(Promise)); | ||
| 102 | + .then(function() { | ||
| 103 | + return Remote.lookup(repository, "origin3") | ||
| 104 | + // We only want to catch the failed lookup | ||
| 105 | + .then(Promise.reject.bind(Promise), Promise.resolve.bind(Promise)); | ||
| 106 | + }); | ||
| 97 | 107 | }); | |
| 98 | 108 | ||
| 99 | 109 | it("can download from a remote", function() { | |
@@ -124,9 +134,7 @@ describe("Remote", function() { | |||
| 124 | 134 | var repo = this.repository; | |
| 125 | 135 | var wasCalled = false; | |
| 126 | 136 | ||
| 127 | - Remote.create(repo, "test2", url2); | ||
| 128 | - | ||
| 129 | - return repo.getRemote("test2") | ||
| 137 | + return Remote.create(repo, "test2", url2) | ||
| 130 | 138 | .then(function(remote) { | |
| 131 | 139 | var fetchOpts = { | |
| 132 | 140 | callbacks: { | |
@@ -183,7 +191,6 @@ describe("Remote", function() { | |||
| 183 | 191 | ||
| 184 | 192 | it("can fetch from a private repository", function() { | |
| 185 | 193 | var repo = this.repository; | |
| 186 | - var remote = Remote.create(repo, "private", privateUrl); | ||
| 187 | 194 | var fetchOptions = { | |
| 188 | 195 | callbacks: { | |
| 189 | 196 | credentials: function(url, userName) { | |
@@ -200,7 +207,10 @@ describe("Remote", function() { | |||
| 200 | 207 | } | |
| 201 | 208 | }; | |
| 202 | 209 | ||
| 203 | - return remote.fetch(null, fetchOptions, "Fetch from private") | ||
| 210 | + return Remote.create(repo, "private", privateUrl) | ||
| 211 | + .then(function(remote) { | ||
| 212 | + return remote.fetch(null, fetchOptions, "Fetch from private"); | ||
| 213 | + }) | ||
| 204 | 214 | .catch(function() { | |
| 205 | 215 | assert.fail("Unable to fetch from private repository"); | |
| 206 | 216 | }); | |
@@ -209,7 +219,6 @@ describe("Remote", function() { | |||
| 209 | 219 | it("can reject fetching from private repository without valid credentials", | |
| 210 | 220 | function() { | |
| 211 | 221 | var repo = this.repository; | |
| 212 | - var remote = Remote.create(repo, "private", privateUrl); | ||
| 213 | 222 | var firstPass = true; | |
| 214 | 223 | var fetchOptions = { | |
| 215 | 224 | callbacks: { | |
@@ -225,7 +234,10 @@ describe("Remote", function() { | |||
| 225 | 234 | } | |
| 226 | 235 | }; | |
| 227 | 236 | ||
| 228 | - return remote.fetch(null, fetchOptions, "Fetch from private") | ||
| 237 | + return Remote.create(repo, "private", privateUrl) | ||
| 238 | + .then(function(remote) { | ||
| 239 | + return remote.fetch(null, fetchOptions, "Fetch from private"); | ||
| 240 | + }) | ||
| 229 | 241 | .then(function () { | |
| 230 | 242 | assert.fail("Should not be able to fetch from repository"); | |
| 231 | 243 | }) | |
@@ -240,19 +252,23 @@ describe("Remote", function() { | |||
| 240 | 252 | ||
| 241 | 253 | it("can fetch from all remotes", function() { | |
| 242 | 254 | var repository = this.repository; | |
| 243 | - Remote.create(repository, "test1", url); | ||
| 244 | - Remote.create(repository, "test2", url2); | ||
| 245 | 255 | ||
| 246 | - return repository.fetchAll({ | ||
| 247 | - callbacks: { | ||
| 248 | - credentials: function(url, userName) { | ||
| 249 | - return NodeGit.Cred.sshKeyFromAgent(userName); | ||
| 250 | - }, | ||
| 251 | - certificateCheck: function() { | ||
| 252 | - return 1; | ||
| 253 | - } | ||
| 254 | - } | ||
| 255 | - }); | ||
| 256 | + return Remote.create(repository, "test1", url) | ||
| 257 | + .then(function() { | ||
| 258 | + return Remote.create(repository, "test2", url2); | ||
| 259 | + }) | ||
| 260 | + .then(function() { | ||
| 261 | + return repository.fetchAll({ | ||
| 262 | + callbacks: { | ||
| 263 | + credentials: function(url, userName) { | ||
| 264 | + return NodeGit.Cred.sshKeyFromAgent(userName); | ||
| 265 | + }, | ||
| 266 | + certificateCheck: function() { | ||
| 267 | + return 1; | ||
| 268 | + } | ||
| 269 | + } | ||
| 270 | + }); | ||
| 271 | + }); | ||
| 256 | 272 | }); | |
| 257 | 273 | ||
| 258 | 274 | it("will reject if credentials promise rejects", function() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments