Skip to content

Commit 84f30fd

Browse files
committed
Update push example
1 parent 8527403 commit 84f30fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/push.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var fileContent = "hello world";
1010
var repoDir = "../../newRepo";
1111

1212
var repository;
13+
var remote;
1314

1415
var signature = nodegit.Signature.create("Foo bar",
1516
"foo@bar.com", 123456789, 60);
@@ -47,15 +48,18 @@ fse.remove(path.resolve(__dirname, repoDir))
4748
.then(function() {
4849
return nodegit.Remote.create(repository, "origin",
4950
"git@github.com:nodegit/push-example.git")
50-
.then(function(remote) {
51-
remote.connect(nodegit.Enums.DIRECTION.PUSH);
51+
.then(function(remoteResult) {
52+
remote = remoteResult;
5253

5354
remote.setCallbacks({
5455
credentials: function(url, userName) {
5556
return nodegit.Cred.sshKeyFromAgent(userName);
5657
}
5758
});
5859

60+
return remote.connect(nodegit.Enums.DIRECTION.PUSH);
61+
})
62+
.then(function() {
5963
// Create the push object for this remote
6064
return remote.push(
6165
["refs/heads/master:refs/heads/master"],

0 commit comments

Comments
 (0)