🐞 fix: More git fixes
Some checks failed
CI / Backend (Rust) (push) Failing after 10s
CI / Frontend (Vue) (push) Successful in 9m57s

This commit is contained in:
Keith Solomon
2026-02-23 18:25:20 -06:00
parent adefed7c74
commit 2a55d5ebec

View File

@@ -115,7 +115,16 @@ fn git_auth_config() -> GitAuthConfig {
.ok() .ok()
.map(PathBuf::from) .map(PathBuf::from)
.filter(|p| p.exists()); .filter(|p| p.exists());
let passphrase = std::env::var("IRONPAD_GIT_SSH_PASSPHRASE").ok(); let passphrase = std::env::var("IRONPAD_GIT_SSH_PASSPHRASE")
.ok()
.and_then(|s| {
let trimmed = s.trim().to_string();
if trimmed.is_empty() {
None
} else {
Some(trimmed)
}
});
GitAuthConfig { GitAuthConfig {
username, username,
@@ -147,11 +156,28 @@ fn remote_callbacks() -> git2::RemoteCallbacks<'static> {
let public_key: Option<&Path> = auth.public_key.as_deref(); let public_key: Option<&Path> = auth.public_key.as_deref();
let passphrase = auth.passphrase.as_deref(); let passphrase = auth.passphrase.as_deref();
match git2::Cred::ssh_key(username, public_key, private_key, passphrase) { // First try with configured public key path (if provided),
// then retry without public key file to avoid mismatch issues.
if let Some(pub_key_path) = public_key {
match git2::Cred::ssh_key(username, Some(pub_key_path), private_key, passphrase) {
Ok(cred) => return Ok(cred),
Err(e) => {
tracing::warn!(
"SSH key auth with explicit public key failed for user '{}', private '{}', public '{}': {}",
username,
private_key.display(),
pub_key_path.display(),
e
);
}
}
}
match git2::Cred::ssh_key(username, None, private_key, passphrase) {
Ok(cred) => return Ok(cred), Ok(cred) => return Ok(cred),
Err(e) => { Err(e) => {
tracing::warn!( tracing::warn!(
"SSH key auth from file failed for user '{}', key '{}': {}", "SSH key auth from private key failed for user '{}', key '{}': {}",
username, username,
private_key.display(), private_key.display(),
e e