Search code examples
node.jsgitlabnodegit

Nodegit https auth


Im trying to implement nodegit to do repo control with gitlab, however I need to use basic username password authentication and the documentation only uses ssh. I've tried to use Cred.userpassPlaintextNew but i get [Error: Too many redirects or authentication replays] like this:

var nodegit = require('nodegit'),
    path = require('path');

var url = "https://gitlab.com/myuser/myrepo.git",
    local = "./clone",
    cloneOpts = {
  fetchOpts: {
    callbacks: {
      credentials: function() {
        return nodegit.Cred.userpassPlaintextNew('myuser','mypass')
      }
    }
  }
};


nodegit.Clone(url, local, cloneOpts).then(function (repo) {
    console.log("Cloned " + path.basename(url) + " to " + repo.workdir());
}).catch(function (err) {
    console.log(err);
});

How can I do this?


Solution

  • Ended up implementing git through child processes. Nodegit library had many issues including locking directories so that you couldn't delete them even after the function returned.