From 1462d3ae20d092bd5d94be1ef09b69e5a77e4ed4 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Thu, 23 Oct 2014 22:17:35 -0400 Subject: [PATCH 1/5] Adds in a broken unit test for #109 --- test/tests/remote.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/tests/remote.js b/test/tests/remote.js index a830f783a..b8e567cf2 100644 --- a/test/tests/remote.js +++ b/test/tests/remote.js @@ -60,4 +60,10 @@ describe("Remote", function() { }); }); }); + + it.only("can push a remote", function() { + return Remote.load(this.repository, "origin").then(function(remote) { + assert(remote.pushurl(), "https://github.com/nodegit/nodegit"); + }); + }); }); From 8c9ff0749a87482043aa810c5137a3faeb5c8b88 Mon Sep 17 00:00:00 2001 From: John Haley Date: Fri, 24 Oct 2014 10:32:00 -0700 Subject: [PATCH 2/5] Fixed seg fault with returning null values --- generate/partials/sync_function.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generate/partials/sync_function.cc b/generate/partials/sync_function.cc index d0f8c995c..43afc5eff 100644 --- a/generate/partials/sync_function.cc +++ b/generate/partials/sync_function.cc @@ -55,6 +55,10 @@ from_{{ arg.name }} {%if not .|returnsCount %} NanReturnUndefined(); {%else%} + if (!result) { + NodeGitPsueodoNanReturnEscapingValue(NanNull()); + } + Handle to; {%if .|returnsCount > 1 %} Handle toReturn = NanNew(); From e44e7474632032560f67dc52c99a3a8a00c52abe Mon Sep 17 00:00:00 2001 From: John Haley Date: Fri, 24 Oct 2014 10:47:22 -0700 Subject: [PATCH 3/5] Apparently you should only null check pointers --- generate/partials/sync_function.cc | 5 ++++- test/tests/attr.js | 6 +++--- test/tests/remote.js | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/generate/partials/sync_function.cc b/generate/partials/sync_function.cc index 43afc5eff..c5fc0297d 100644 --- a/generate/partials/sync_function.cc +++ b/generate/partials/sync_function.cc @@ -55,9 +55,12 @@ from_{{ arg.name }} {%if not .|returnsCount %} NanReturnUndefined(); {%else%} + {%if return.cType | isPointer %} + // null checks on pointers if (!result) { - NodeGitPsueodoNanReturnEscapingValue(NanNull()); + NodeGitPsueodoNanReturnEscapingValue(NanUndefined()); } + {%endif%} Handle to; {%if .|returnsCount > 1 %} diff --git a/test/tests/attr.js b/test/tests/attr.js index b6973cf40..878c445fd 100644 --- a/test/tests/attr.js +++ b/test/tests/attr.js @@ -1,7 +1,7 @@ var assert = require("assert"); var path = require("path"); -describe("Blob", function() { +describe("Attr", function() { var reposPath = path.resolve("test/repos/workdir/.git"); var Repository = require("../../lib/repository"); @@ -29,11 +29,11 @@ describe("Blob", function() { it.skip("can lookup the value of a git attribute", function() { var flags = Attr.Check.NO_SYSTEM; var getAttr = Attr.get(this.repository, flags, ".gitattributes", "test"); - + return getAttr.then(function(val) { console.log(val); }).catch(function(ex) { - console.log(ex); + console.log(ex); }); }); }); diff --git a/test/tests/remote.js b/test/tests/remote.js index b8e567cf2..3e0c24cf1 100644 --- a/test/tests/remote.js +++ b/test/tests/remote.js @@ -61,7 +61,7 @@ describe("Remote", function() { }); }); - it.only("can push a remote", function() { + it("can push a remote", function() { return Remote.load(this.repository, "origin").then(function(remote) { assert(remote.pushurl(), "https://github.com/nodegit/nodegit"); }); From 9b2a6afb5c952fc5bed70e948d303accf89f982c Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Fri, 24 Oct 2014 14:36:15 -0400 Subject: [PATCH 4/5] Added set push url and another segfault --- generate/descriptor.json | 5 +++++ test/tests/remote.js | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index 2483a94f5..4059ac527 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -699,6 +699,11 @@ "args": [{ "isSelf": true }] }, + "git_remote_set_pushurl": { + "ignore": false, + "args": [{ "isSelf": true }] + }, + "git_remote_load": { "ignore": false, "isConstructorMethod": true, diff --git a/test/tests/remote.js b/test/tests/remote.js index 3e0c24cf1..2aea7a2aa 100644 --- a/test/tests/remote.js +++ b/test/tests/remote.js @@ -7,22 +7,33 @@ describe("Remote", function() { var Repository = require("../../lib/repository"); var Remote = require("../../lib/remote"); + function removeOrigins(repository) { + return Remote.load(repository, "origin1").then(function(remote) { + remote.delete(); + + return Remote.load(repository, "origin2").then(function(remote) { + remote.delete(); + }); + }).catch(function() {}); + } + before(function() { var test = this; return Repository.open(reposPath).then(function(repository) { test.repository = repository; + return Remote.load(repository, "origin").then(function(remote) { test.remote = remote; + + return removeOrigins(repository); }); }); }); after(function() { - return Remote.load(this.repository, "origin2").then(function(remote) { - remote.delete(); - }); + return removeOrigins(this.repository); }); it("can load a remote", function() { @@ -35,6 +46,21 @@ describe("Remote", function() { "https://github.com/nodegit/nodegit"); }); + it("can push a remote", function() { + assert.equal(this.remote.pushurl(), undefined); + }); + + it("can set a remote", function() { + var repository = this.repository; + var url = "https://github.com/nodegit/nodegit"; + + return Remote.create(repository, "origin1", url).then(function(remote) { + return remote.setPushurl("https://google.com/", function() { + assert(remote.pushurl(), "https://google.com/"); + }); + }); + }); + it("can read the remote name", function() { assert.equal(this.remote.name(), "origin"); }); @@ -60,10 +86,4 @@ describe("Remote", function() { }); }); }); - - it("can push a remote", function() { - return Remote.load(this.repository, "origin").then(function(remote) { - assert(remote.pushurl(), "https://github.com/nodegit/nodegit"); - }); - }); }); From 76884527fa693d2773b6025d55d014ee0b10740b Mon Sep 17 00:00:00 2001 From: Max Korp Date: Fri, 24 Oct 2014 15:28:18 -0700 Subject: [PATCH 5/5] fix segfault in "remote: can set a remote --- generate/descriptor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate/descriptor.json b/generate/descriptor.json index 4059ac527..0131afbd1 100644 --- a/generate/descriptor.json +++ b/generate/descriptor.json @@ -701,7 +701,7 @@ "git_remote_set_pushurl": { "ignore": false, - "args": [{ "isSelf": true }] + "args": [{ "isSelf": true, "isReturn": false }] }, "git_remote_load": {