git2go icon indicating copy to clipboard operation
git2go copied to clipboard

No error message for wrong auth

Open runemadsen opened this issue 8 years ago • 2 comments

I'm trying to use the CredentialsCallback when pushing, and it's all working:

err = remote.Push([]string{"refs/heads/" + branch}, &git.PushOptions{
		RemoteCallbacks: git.RemoteCallbacks{
			CredentialsCallback: func(url string, username_from_url string, allowed_types git.CredType) (git.ErrorCode, *git.Cred) {
				if called {
					return git.ErrUser, nil
				}
				called = true
				ret, creds := git.NewCredUserpassPlaintext(user, pass)
				return git.ErrorCode(ret), &creds
			},
		},
	})
fmt.Println(err)

This code tries the credentials once, then fails. However, while returning git.ErrUser in the callback, remote.Push simply returns an empty go error with no message, so there's no way for me of knowing that it was git.ErrUser. Am I doing something wrong? Shouldn't my last Println print a message?

runemadsen avatar Feb 22 '17 02:02 runemadsen

Hi ! I recently dealt with that and I figured out that it requires the callback CertificateCheckCallback to be defined as well. Example here https://github.com/jwaldrip/git-get/blob/master/callbacks.go#L17

apflieger avatar Feb 22 '17 09:02 apflieger

Thanks so much @apflieger! I'll give it a try.

runemadsen avatar Feb 22 '17 18:02 runemadsen