Пример #1
0
func credentialsCallback(url, username string, allowedTypes git.CredType) (git.ErrorCode, *git.Cred) {
	ret, cred := git.NewCredSshKeyFromAgent(username)
	code := git.ErrorCode(ret)

	// TODO: get user:pass in cli.... add as args?

	return code, &cred // TODO: return ptr? seems weird
}
Пример #2
0
func certificateCheckCallback(cert *git.Certificate, valid bool, hostname string) git.ErrorCode {
	// TODO: !!!!!!!!!!!!!!!!
	return git.ErrorCode(0)
}
Пример #3
0
)

var remoteCallbacks = git.RemoteCallbacks{
	CredentialsCallback: func(url string, username_from_url string, allowed_types git.CredType) (git.ErrorCode, *git.Cred) {
		pubKey, err := homedir.Expand("~/.ssh/id_rsa.pub")
		if err != nil {
			return git.ErrAuth, nil
		}

		privKey, err := homedir.Expand("~/.ssh/id_rsa")
		if err != nil {
			return git.ErrAuth, nil
		}

		code, key := git.NewCredSshKey("git", pubKey, privKey, "")
		return git.ErrorCode(code), &key
	},
	CertificateCheckCallback: func(cert *git.Certificate, valid bool, hostname string) git.ErrorCode {
		if cert.Kind == git.CertificateHostkey {
			return git.ErrOk
		} else if valid {
			return git.ErrOk
		}
		return git.ErrAuth
	},
}

func (p *Project) Remotes() *git.RemoteCollection {
	return &p.repo.Remotes
}