Skip to content

Commit 424c18d

Browse files
John Haleytbranyen
authored andcommitted
Starting work on CloneOptions
1 parent 2af57be commit 424c18d

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

generate/descriptor.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@
166166
"../include/checkout_options.h",
167167
"../include/remote_callbacks.h"
168168
],
169-
"fields": []
169+
"fields": [
170+
{
171+
"name": "ignore_cert_errors",
172+
"cType": "int"
173+
}
174+
]
170175
},
171176

172177
"commit": {

lib/clone_options.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var NodeGit = require("../");
2+
var CloneOptions = NodeGit.CloneOptions;
3+
4+
/**
5+
* Turn a JavaScript object into a CloneObject
6+
*
7+
* @param {Object} obj - The JS object to be converted
8+
* @return {Object} A CloneObject instance.
9+
*/
10+
CloneOptions.fromObj = function(obj) {
11+
try {
12+
if (typeof obj != "object") return null;
13+
14+
var result = new CloneOptions();
15+
16+
Object.keys(obj).forEach(function(property) {
17+
result[property] = obj[property];
18+
});
19+
20+
return result;
21+
}
22+
catch (ex) {
23+
return null;
24+
}
25+
}
26+
27+
module.exports = CloneOptions;

test/tests/clone.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe("Clone", function() {
1212

1313
var Repository = require("../../lib/repository");
1414
var Clone = require("../../lib/clone");
15+
var CloneOptions = require("../../lib/clone_options");
1516

1617
before(function() {
1718
return Promise.all([
@@ -24,8 +25,9 @@ describe("Clone", function() {
2425

2526
it("can clone with http", function() {
2627
var url = "http://github.com/nodegit/test.git";
28+
var opts = CloneOptions.fromObj({ ignoreCertErrors: 1});
2729

28-
return Clone.clone(url, http, null).then(function(repository) {
30+
return Clone.clone(url, http, opts).then(function(repository) {
2931
assert.ok(repository instanceof Repository);
3032
});
3133
});

0 commit comments

Comments
 (0)