Address issue #172, to use public key path if present in preference

to using password.
This commit is contained in:
mendrak
2023-03-25 09:36:43 -07:00
parent 3c50df7af0
commit 74342b298e
2 changed files with 11 additions and 7 deletions

1
.gitmodules vendored
View File

@@ -5,6 +5,7 @@
[submodule "libgit2"]
path = thirdparty/git2/libgit2
url = https://github.com/libgit2/libgit2
ignore = untracked
[submodule "thirdparty/ssh2/libssh2"]
path = thirdparty/ssh2/libssh2
url = https://github.com/libssh2/libssh2

View File

@@ -82,17 +82,20 @@ extern "C" int credentials_cb(git_cred **out, const char *url, const char *usern
godot::String proper_username = username_from_url ? username_from_url : creds->username;
if (!creds->ssh_public_key_path.is_empty()) {
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
return git_credential_ssh_key_new(out,
CString(proper_username).data,
CString(creds->ssh_public_key_path).data,
CString(creds->ssh_private_key_path).data,
CString(creds->ssh_passphrase).data);
}
}
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
}
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
return git_credential_ssh_key_new(out,
CString(proper_username).data,
CString(creds->ssh_public_key_path).data,
CString(creds->ssh_private_key_path).data,
CString(creds->ssh_passphrase).data);
}
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
return git_credential_username_new(out, CString(proper_username).data);