Skip to content

Push #463

Closed
Closed

Description

@rafaelfaria

Guys,

I promise that before i posted this i looked everywhere, and tried to understand the documentation the best i could, but because there is no description on the methods in the documentation it's been pretty hard to decipher what needs to be done.

I'm trying to do a simple push, but nothing i do it seems be working.

The example it's commited on this repo, it create a repo. In my case it already exists. So instead of "create" im trying to use 'load'. Again, because o f the lack of the description i'm not even sure if that's the right way to do it. I'm basing myself from the tests. I saw a few functions using load.

var repo;

nodegit.Repository.open(repoFolder)
    .then(function(repoResult) {
        repo = repoResult;
        return repoResult.openIndex();
    })

         ... COMMIT FUNCTION HERE IS ALREADY WORKING ..

    .then(function() {
        return nodegit.Remote.load(repo, "origin").then(function(remote) { 
                remote.connect(nodegit.Enums.DIRECTION.PUSH);
                remote.setCallbacks({
                    credentials: function(url, userName) {
                        return nodegit.Cred.sshKeyFromAgent(userName);
                    }
                });

                console.log('Connected?', remote.connected())

                console.log(remote.push) // this returns undefined
             });

    })

This returns "Connected? 0".

I know i need to do a push in the remote, but for some reason the "push" method is undefined.

Please.... i'm pretty frustrated. Being trying to get this working for about 5 hours now, trying to do a simple push from my origin.

Any help would be appreciated.

Thanks

Activity

  1. rafaelfaria commented on Mar 6, 2015

    @rafaelfaria
    Author

    Thanks to @maxkorp I actually managed to get this working if anyone else is interested in the asnwer.

    var repo, remote;
    
    nodegit.Repository.open(repoFolder)
        .then(function(repoResult) {
            repo = repoResult;
            return repoResult.openIndex();
        })
        .then(function() {
            return repo.getRemote("origin");
        }).then(function(remoteResult) {
    
          console.log('remote Loaded');
          remote = remoteResult;
          remote.setCallbacks({
              credentials: function(url, userName) {
                  return nodegit.Cred.sshKeyFromAgent(userName);
              }
          });
          console.log('remote Configured');
          return remote.connect(nodegit.Enums.DIRECTION.PUSH);
        }).then(function() {
          console.log('remote Connected?', remote.connected())
    
          return remote.push(
                    ["refs/heads/master:refs/heads/master"],
                    null,
                    repo.defaultSignature(),
                    "Push to master")
        }).then(function() {
          console.log('remote Pushed!')
        })
        .catch(function(reason) {
            console.log(reason);
        })
    
  2. maxkorp commented on Mar 6, 2015

    @maxkorp
    Collaborator

    👍

  3. chainsys commented on Sep 16, 2015

    @chainsys

    push pdf,.docx,img file format not working thorwing this ERROR: [Error: Request failed with status code: 500]

  4. Molnfront commented on Nov 3, 2015

    @Molnfront

    After adding some essential code at the beginning of the example I get:

    remote Loaded
    [TypeError: undefined is not a function]

    I always got it at this line (11) :

    }).then(function(remoteResult) {

    I have tried a lot of examples...

    nodegit 0.5.0
    nodejs 0.12.7
    Ubuntu 14.04 or OSX

    More debug info, from another test:

    TypeError: undefined is not a function
    at /home/test/Dokument/node-auth0-sample_nodegit_local2/serverexeample.js:52:6
    at tryCallOne (/home/test/Dokument/node-auth0-sample_nodegit_local2/node_modules/nodegit-promise/lib/core.js:37:12)
    at /home/test/Dokument/node-auth0-sample_nodegit_local2/node_modules/nodegit-promise/lib/core.js:103:15
    at flush (/home/test/Dokument/node-auth0-sample_nodegit_local2/node_modules/nodegit-promise/node_modules/asap/raw.js:50:29)
    at process._tickCallback (node.js:355:11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions