git2go
git2go copied to clipboard
Can't figure out how to use NewCredUserpassPlaintext() properly
Hello,
I am trying to clone a password protected http git repo using NewCredUserpassPlaintext() function by passing the credentials to git.CloneOptions struct as shown in code bellow, but it does not work for me and I get a: No Content-Type header in response.
Cloning the same http repo using git command-line works fine. Would you please point out to me what I am doing wrong ?
package main
import "gopkg.in/libgit2/git2go.v23"
func credentialsCallback(url string, username string, allowedTypes git.CredType) (git.ErrorCode, *git.Cred) {
ret, cred := git.NewCredUserpassPlaintext("username", "password")
return git.ErrorCode(ret), &cred
}
func main() {
cloneOptions := &git.CloneOptions{}
cloneOptions.FetchOptions = &git.FetchOptions{
RemoteCallbacks: git.RemoteCallbacks{
CredentialsCallback: credentialsCallback,
},
}
repo, err := git.Clone("http://IP-address:port/private-repository.git", "private-repo", cloneOptions)
if err != nil {
Panic(err)
}
}
That error message isn't related to the password, the server isn't sending the right kind of response. Chances are that you're hitting a repo that expects to be downloaded via dumb HTTP, WHICH git2go/libgit2 doesn't support.