From 0b68be0b4cec332e8768173f99b08bb313f9beda Mon Sep 17 00:00:00 2001 From: John Haley Date: Wed, 4 Mar 2015 13:56:31 -0700 Subject: [PATCH] Fix push example --- examples/push.js | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/examples/push.js b/examples/push.js index e5322397f..91d012d25 100644 --- a/examples/push.js +++ b/examples/push.js @@ -47,37 +47,22 @@ fse.remove(path.resolve(__dirname, repoDir)) .then(function() { return nodegit.Remote.create(repository, "origin", "git@github.com:nodegit/push-example.git") - .then(function(remote) { - remote.connect(nodegit.Enums.DIRECTION.PUSH); + .then(function(remote) { + remote.connect(nodegit.Enums.DIRECTION.PUSH); - var push; - - // We need to set the auth on the remote, not the push object - remote.setCallbacks({ - credentials: function(url, userName) { - return nodegit.Cred.sshKeyFromAgent(userName); - } - }); - - // Create the push object for this remote - return remote.push( - ["refs/heads/master:refs/heads/master"], - null, - repository.defaultSignature(), - "Push to master") - .then(function(pushResult) { - push = pushResult; - - // This just says what branch we're pushing onto what remote branch - return push.addRefspec("refs/heads/master:refs/heads/master"); - }).then(function() { - // This is the call that performs the actual push - return push.finish(); - }).then(function() { - // Check to see if the remote accepted our push request. - return push.unpackOk(); - }); + remote.setCallbacks({ + credentials: function(url, userName) { + return nodegit.Cred.sshKeyFromAgent(userName); + } }); + + // Create the push object for this remote + return remote.push( + ["refs/heads/master:refs/heads/master"], + null, + repository.defaultSignature(), + "Push to master"); + }); }).done(function() { console.log("Done!"); });