Skip to content

Commit abd75e5

Browse files
committed
Merge pull request #794 from nodegit/async-set-upstream
Make `Branch.setUpstream` and `Branch.upstream` async
2 parents b0fec17 + aeb9a0a commit abd75e5

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎generate/input/descriptor.json‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,21 @@
178178
"ignore": true
179179
},
180180
"git_branch_set_upstream": {
181-
"isAsync": false,
181+
"isAsync": true,
182182
"args": {
183183
"upstream_name": {
184184
"isOptional": true
185185
}
186+
},
187+
"return" : {
188+
"isReturn": true,
189+
"isErrorCode": true
186190
}
187191
},
188192
"git_branch_upstream": {
189-
"isAsync": false,
193+
"isAsync": true,
190194
"return" : {
195+
"isReturn": true,
191196
"isErrorCode": true
192197
}
193198
}

‎generate/scripts/helpers.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,10 @@ var Helpers = {
289289
// available
290290
if (key == typeDef.cType + "_free") {
291291
typeDef.freeFunctionName = key;
292-
//fnDef.ignore = true;
293-
//return;
294292
}
295293

296294
fnDef.cppFunctionName = Helpers.cTypeToCppName(key, "git_" + typeDef.typeName);
297295
fnDef.jsFunctionName = Helpers.cTypeToJsName(key, "git_" + typeDef.typeName);
298-
//fnDef.isAsync = false; // until proven otherwise
299296

300297
if (fnDef.cppFunctionName == typeDef.cppClassName) {
301298
fnDef.cppFunctionName = fnDef.cppFunctionName.replace("Git", "");

‎test/tests/branch.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe("Branch", function() {
99
var Branch = NodeGit.Branch;
1010
var branchName = "test-branch";
1111
var fullBranchName = "refs/heads/" + branchName;
12+
var upstreamName = "origin/master";
1213

1314
var reposPath = local("../repos/workdir");
1415

@@ -56,4 +57,16 @@ describe("Branch", function() {
5657
assert.ok(branch.isHead());
5758
});
5859
});
60+
61+
it("can set an upstream for a branch", function() {
62+
var branch = this.branch;
63+
64+
return NodeGit.Branch.setUpstream(branch, upstreamName)
65+
.then(function() {
66+
return NodeGit.Branch.upstream(branch);
67+
})
68+
.then(function(upstream) {
69+
assert.equal(upstream.shorthand(), upstreamName);
70+
});
71+
});
5972
});

0 commit comments

Comments
 (0)