我正在尝试从pygit2
/内部推送引用libgit2
:
push_refspec = git_repo.lookup_reference('HEAD').resolve().name
logger.info("Pushing " + push_refspec)
git_remote.push(push_refspec)
但是,我收到有关缺少凭据的错误:
_pygit2.GitError: Cannot set up SSH connection without credentials
这最终来自( )libssh2
的调用:libgit2
transports/ssh.c
if (user && pass) {
if (git_cred_userpass_plaintext_new(&t->cred, user, pass) < 0)
goto on_error;
} else if (t->owner->cred_acquire_cb) {
if (t->owner->cred_acquire_cb(
&t->cred, t->owner->url, user,
GIT_CREDTYPE_USERPASS_PLAINTEXT |
GIT_CREDTYPE_SSH_KEY |
GIT_CREDTYPE_SSH_CUSTOM,
t->owner->cred_acquire_payload) < 0)
goto on_error;
if (!t->cred) {
giterr_set(GITERR_SSH, "Callback failed to initialize SSH credentials");
goto on_error;
}
} else {
giterr_set(GITERR_SSH, "Cannot set up SSH connection without credentials");
goto on_error;
}
使用 Git 客户端的存储库中的Apush
工作得很好。我试过GIT_SSL_NO_VERIFY=true
哪个(不出所料)不起作用。
我需要设置哪些额外信息才能使其正常工作?