3

I'm trying to use NodeGit to download some tutorials for my application from private repositories. I'm using a token to authenticate and download them via https. The problem is, if user has set

[url "git@github.com:"]
    insteadOf = https://github.com/

in .gitconfig, it will fail with callback returned unsupported credentials type error. I tried using Config API, but not sure if I was doing this correctly, because there is no description for this in docs.

Here is my code:

fse     = require 'fs-extra'
Git     = require 'nodegit'

...

cloneOpts =
    fetchOpts:
        callbacks:
            certificateCheck: => 1
            credentials: (url, userName) =>
                return Git.Cred.userpassPlaintextNew(myUser, myToken)
            transferProgress: (stats) =>
                p = (stats.receivedObjects() + stats.indexedObjects()) / (stats.totalObjects() * 2)
                try
                    progress p
                catch error
                    console.log error
fse.remove dstPath, (err) =>
    Git.Clone(tutorial.uri, dstPath, cloneOpts)
        .then((repo) =>
            console.log 'success')
        .catch((error) =>
            console.log error.message)

How can I make NodeGit ignore users' .gitconfig?

remdezx
  • 2,939
  • 28
  • 49

0 Answers0