Skip to content

Commit 1528a01

Browse files
committed
Added additional remote methods
Added the following methods: - git_remote_create - git_remote_rename - git_remote_name - git_remote_pushurl (untested, has been segfaulting) - git_remote_delete
1 parent 8de1cd5 commit 1528a01

File tree

4 files changed

+85
-7
lines changed

4 files changed

+85
-7
lines changed

.jshintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"it": true,
1919
"describe": true,
2020
"before": true,
21-
"beforeEach": true
21+
"beforeEach": true,
22+
"after": true,
23+
"afterEach": true
2224
}
2325
}

generate/descriptor.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,38 @@
555555
}
556556
},
557557

558-
"git_remote_load": {
558+
"git_remote_create": {
559559
"ignore": false,
560560
"isConstructorMethod": true
561561
},
562562

563+
"git_remote_rename": {
564+
"ignore": false
565+
},
566+
567+
"git_remote_name": {
568+
"ignore": false,
569+
"args": [{ "isSelf": true }]
570+
},
571+
572+
"git_remote_pushurl": {
573+
"ignore": false,
574+
"args": [{ "isSelf": true }]
575+
},
576+
577+
"git_remote_load": {
578+
"ignore": false,
579+
"isConstructorMethod": true,
580+
"return": {
581+
"copy": "git_remote_dup"
582+
}
583+
},
584+
585+
"git_remote_delete": {
586+
"ignore": false,
587+
"args": [{ "isReturn": false, "isSelf": true }]
588+
},
589+
563590
"git_remote_url": {
564591
"ignore": false,
565592
"args": [{ "isSelf": true }]

generate/types.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,5 +9055,17 @@
90559055
"const git_strarray **": {
90569056
"cpp": "GitStrarray",
90579057
"js": "Strarray"
9058+
},
9059+
"git_remote_delete": {
9060+
"cpp": "Delete",
9061+
"js": "delete"
9062+
},
9063+
"git_remote_delete *": {
9064+
"cpp": "Delete",
9065+
"js": "delete"
9066+
},
9067+
"const git_remote_delete *": {
9068+
"cpp": "Delete",
9069+
"js": "delete"
90589070
}
90599071
}

test/tests/remote.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var assert = require("assert");
22
var path = require("path");
33

4-
describe("Repository", function() {
4+
describe("Remote", function() {
55
var reposPath = path.resolve("test/repos/workdir/.git");
66

77
var Repository = require("../../lib/repository");
@@ -12,13 +12,50 @@ describe("Repository", function() {
1212

1313
return Repository.open(reposPath).then(function(repository) {
1414
test.repository = repository;
15+
16+
return Remote.load(repository, "origin").then(function(remote) {
17+
test.remote = remote;
18+
});
19+
});
20+
});
21+
22+
after(function() {
23+
return Remote.load(this.repository, "origin2").then(function(remote) {
24+
remote.delete();
1525
});
1626
});
1727

18-
it("can read git remote url", function() {
19-
return Remote.load(this.repository, "origin").then(function(remote) {
20-
assert.ok(remote instanceof Remote);
21-
assert.equal(remote.url(), "https://github.com/nodegit/nodegit");
28+
it("can load a remote", function() {
29+
assert.ok(this.remote instanceof Remote);
30+
});
31+
32+
it("can read the remote url", function() {
33+
assert.equal(this.remote.url(), "https://github.com/nodegit/nodegit");
34+
});
35+
36+
it("can read the remote name", function() {
37+
assert.equal(this.remote.name(), "origin");
38+
});
39+
40+
it("can create a new remote", function() {
41+
var repository = this.repository;
42+
var url = "https://github.com/nodegit/nodegit";
43+
44+
return Remote.create(repository, "origin2", url).then(function() {
45+
return Remote.load(repository, "origin2").then(function(remote) {
46+
assert(remote.url(), "https://github.com/nodegit/nodegit");
47+
});
48+
});
49+
});
50+
51+
it("can delete a remote", function() {
52+
var repository = this.repository;
53+
var url = "https://github.com/nodegit/nodegit";
54+
55+
return Remote.create(repository, "origin3", url).then(function() {
56+
return Remote.load(repository, "origin3").then(function(remote) {
57+
remote.delete();
58+
});
2259
});
2360
});
2461
});

0 commit comments

Comments
 (0)