Skip to content

Commit 25feff1

Browse files
committed
Merge pull request nodegit#462 from nodegit/fix-push-example
Fix push example
2 parents c620497 + 0b68be0 commit 25feff1

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

examples/push.js

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,22 @@ fse.remove(path.resolve(__dirname, repoDir))
4747
.then(function() {
4848
return nodegit.Remote.create(repository, "origin",
4949
"git@github.com:nodegit/push-example.git")
50-
.then(function(remote) {
51-
remote.connect(nodegit.Enums.DIRECTION.PUSH);
50+
.then(function(remote) {
51+
remote.connect(nodegit.Enums.DIRECTION.PUSH);
5252

53-
var push;
54-
55-
// We need to set the auth on the remote, not the push object
56-
remote.setCallbacks({
57-
credentials: function(url, userName) {
58-
return nodegit.Cred.sshKeyFromAgent(userName);
59-
}
60-
});
61-
62-
// Create the push object for this remote
63-
return remote.push(
64-
["refs/heads/master:refs/heads/master"],
65-
null,
66-
repository.defaultSignature(),
67-
"Push to master")
68-
.then(function(pushResult) {
69-
push = pushResult;
70-
71-
// This just says what branch we're pushing onto what remote branch
72-
return push.addRefspec("refs/heads/master:refs/heads/master");
73-
}).then(function() {
74-
// This is the call that performs the actual push
75-
return push.finish();
76-
}).then(function() {
77-
// Check to see if the remote accepted our push request.
78-
return push.unpackOk();
79-
});
53+
remote.setCallbacks({
54+
credentials: function(url, userName) {
55+
return nodegit.Cred.sshKeyFromAgent(userName);
56+
}
8057
});
58+
59+
// Create the push object for this remote
60+
return remote.push(
61+
["refs/heads/master:refs/heads/master"],
62+
null,
63+
repository.defaultSignature(),
64+
"Push to master");
65+
});
8166
}).done(function() {
8267
console.log("Done!");
8368
});

0 commit comments

Comments
 (0)