|
1 | | -var assert = require("assert"); |
2 | | -var path = require("path"); |
3 | | -var Promise = require("nodegit-promise"); |
4 | | -var promisify = require("promisify-node"); |
5 | | -var fse = promisify(require("fs-extra")); |
6 | | -var local = path.join.bind(path, __dirname); |
7 | | - |
8 | | -describe("Clone", function() { |
9 | | - var http = local("../repos/http"); |
10 | | - var https = local("../repos/https"); |
11 | | - var ssh = local("../repos/ssh"); |
12 | | - var sshManual = local("../repos/sshmanual"); |
13 | | - var git = local("../repos/git"); |
14 | | - var file = local("../repos/file"); |
15 | | - |
16 | | - var sshPublicKey = local("../id_rsa.pub"); |
17 | | - var sshPrivateKey = local("../id_rsa"); |
18 | | - |
19 | | - var Repository = require(local("../../lib/repository")); |
20 | | - var Clone = require(local("../../lib/clone")); |
21 | | - var NodeGit = require(local("../../")); |
22 | | - |
23 | | - // Set a reasonable timeout here now that our repository has grown. |
24 | | - this.timeout(15000); |
25 | | - |
26 | | - before(function() { |
27 | | - return Promise.all([ |
28 | | - fse.remove(http), |
29 | | - fse.remove(https), |
30 | | - fse.remove(ssh), |
31 | | - fse.remove(sshManual), |
32 | | - fse.remove(git), |
33 | | - fse.remove(file), |
34 | | - ]); |
35 | | - }); |
36 | | - |
37 | | - it("can clone with http", function() { |
38 | | - var url = "http://github.com/nodegit/test.git"; |
39 | | - var opts = { ignoreCertErrors: 1 }; |
40 | | - |
41 | | - return Clone.clone(url, http, opts).then(function(repository) { |
42 | | - assert.ok(repository instanceof Repository); |
43 | | - }); |
44 | | - }); |
45 | | - |
46 | | - it("can clone with https", function() { |
47 | | - var url = "https://github.com/nodegit/test.git"; |
48 | | - var opts = { ignoreCertErrors: 1 }; |
49 | | - |
50 | | - return Clone.clone(url, https, opts).then(function(repository) { |
51 | | - assert.ok(repository instanceof Repository); |
52 | | - }); |
53 | | - }); |
54 | | - |
55 | | - it("can clone with ssh", function() { |
56 | | - var url = "git@github.com:nodegit/test.git"; |
57 | | - var opts = { |
58 | | - ignoreCertErrors: 1, |
59 | | - remoteCallbacks: { |
60 | | - credentials: function(url, userName) { |
61 | | - return NodeGit.Cred.sshKeyFromAgent(userName); |
62 | | - } |
63 | | - } |
64 | | - }; |
65 | | - |
66 | | - return Clone.clone(url, ssh, opts).then(function(repository) { |
67 | | - assert.ok(repository instanceof Repository); |
68 | | - }); |
69 | | - }); |
70 | | - |
71 | | - it("can clone with ssh while manually loading a key", function() { |
72 | | - var url = "git@github.com:nodegit/test.git"; |
73 | | - var opts = { |
74 | | - ignoreCertErrors: 1, |
75 | | - remoteCallbacks: { |
76 | | - credentials: function(url, userName) { |
77 | | - return NodeGit.Cred.sshKeyNew( |
78 | | - userName, |
79 | | - sshPublicKey, |
80 | | - sshPrivateKey, |
81 | | - ""); |
82 | | - } |
83 | | - } |
84 | | - }; |
85 | | - |
86 | | - return Clone.clone(url, sshManual, opts).then(function(repository) { |
87 | | - assert.ok(repository instanceof Repository); |
88 | | - }); |
89 | | - }); |
90 | | - |
91 | | - it("can clone with git", function() { |
92 | | - var url = "git://github.com/nodegit/test.git"; |
93 | | - var opts = { ignoreCertErrors: 1 }; |
94 | | - |
95 | | - return Clone.clone(url, git, opts).then(function(repository) { |
96 | | - assert.ok(repository instanceof Repository); |
97 | | - }); |
98 | | - }); |
99 | | - |
100 | | - it("can clone with filesystem", function() { |
101 | | - var prefix = process.platform === "win32" ? "" : "file://"; |
102 | | - var url = prefix + local("../repos/empty"); |
103 | | - |
104 | | - return Clone.clone(url, file).then(function(repository) { |
105 | | - assert.ok(repository instanceof Repository); |
106 | | - }); |
107 | | - }); |
108 | | -}); |
| 1 | +var assert = require("assert"); |
| 2 | +var path = require("path"); |
| 3 | +var Promise = require("nodegit-promise"); |
| 4 | +var promisify = require("promisify-node"); |
| 5 | +var fse = promisify(require("fs-extra")); |
| 6 | +var local = path.join.bind(path, __dirname); |
| 7 | + |
| 8 | +describe("Clone", function() { |
| 9 | + var http = local("../repos/http"); |
| 10 | + var https = local("../repos/https"); |
| 11 | + var ssh = local("../repos/ssh"); |
| 12 | + var sshManual = local("../repos/sshmanual"); |
| 13 | + var git = local("../repos/git"); |
| 14 | + var file = local("../repos/file"); |
| 15 | + |
| 16 | + var sshPublicKey = local("../id_rsa.pub"); |
| 17 | + var sshPrivateKey = local("../id_rsa"); |
| 18 | + |
| 19 | + var Repository = require(local("../../lib/repository")); |
| 20 | + var Clone = require(local("../../lib/clone")); |
| 21 | + var NodeGit = require(local("../../")); |
| 22 | + |
| 23 | + // Set a reasonable timeout here now that our repository has grown. |
| 24 | + this.timeout(15000); |
| 25 | + |
| 26 | + before(function() { |
| 27 | + return Promise.all([ |
| 28 | + fse.remove(http), |
| 29 | + fse.remove(https), |
| 30 | + fse.remove(ssh), |
| 31 | + fse.remove(sshManual), |
| 32 | + fse.remove(git), |
| 33 | + fse.remove(file), |
| 34 | + ]); |
| 35 | + }); |
| 36 | + |
| 37 | + it("can clone with http", function() { |
| 38 | + var url = "http://github.com/nodegit/test.git"; |
| 39 | + var opts = { ignoreCertErrors: 1 }; |
| 40 | + |
| 41 | + return Clone.clone(url, http, opts).then(function(repository) { |
| 42 | + assert.ok(repository instanceof Repository); |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + it("can clone with https", function() { |
| 47 | + var url = "https://github.com/nodegit/test.git"; |
| 48 | + var opts = { ignoreCertErrors: 1 }; |
| 49 | + |
| 50 | + return Clone.clone(url, https, opts).then(function(repository) { |
| 51 | + assert.ok(repository instanceof Repository); |
| 52 | + }); |
| 53 | + }); |
| 54 | + |
| 55 | + it("can clone with ssh", function() { |
| 56 | + var url = "git@github.com:nodegit/test.git"; |
| 57 | + var opts = { |
| 58 | + ignoreCertErrors: 1, |
| 59 | + remoteCallbacks: { |
| 60 | + credentials: function(url, userName) { |
| 61 | + return NodeGit.Cred.sshKeyFromAgent(userName); |
| 62 | + } |
| 63 | + } |
| 64 | + }; |
| 65 | + |
| 66 | + return Clone.clone(url, ssh, opts).then(function(repository) { |
| 67 | + assert.ok(repository instanceof Repository); |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + it("can clone with ssh while manually loading a key", function() { |
| 72 | + var url = "git@github.com:nodegit/test.git"; |
| 73 | + var opts = { |
| 74 | + ignoreCertErrors: 1, |
| 75 | + remoteCallbacks: { |
| 76 | + credentials: function(url, userName) { |
| 77 | + return NodeGit.Cred.sshKeyNew( |
| 78 | + userName, |
| 79 | + sshPublicKey, |
| 80 | + sshPrivateKey, |
| 81 | + ""); |
| 82 | + } |
| 83 | + } |
| 84 | + }; |
| 85 | + |
| 86 | + return Clone.clone(url, sshManual, opts).then(function(repository) { |
| 87 | + assert.ok(repository instanceof Repository); |
| 88 | + }); |
| 89 | + }); |
| 90 | + |
| 91 | + it("can clone with git", function() { |
| 92 | + var url = "git://github.com/nodegit/test.git"; |
| 93 | + var opts = { ignoreCertErrors: 1 }; |
| 94 | + |
| 95 | + return Clone.clone(url, git, opts).then(function(repository) { |
| 96 | + assert.ok(repository instanceof Repository); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + it("can clone with filesystem", function() { |
| 101 | + var prefix = process.platform === "win32" ? "" : "file://"; |
| 102 | + var url = prefix + local("../repos/empty"); |
| 103 | + |
| 104 | + return Clone.clone(url, file).then(function(repository) { |
| 105 | + assert.ok(repository instanceof Repository); |
| 106 | + }); |
| 107 | + }); |
| 108 | +}); |
0 commit comments