diff --git a/src/main.rs b/src/main.rs index e3e0cfd..f958050 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,6 +41,9 @@ async fn main() -> eyre::Result<()> { let mut cb = RemoteCallbacks::new(); cb.credentials(|_, _, _| { + if let Some(sock) = std::env::var("SSH_AUTH_SOCK").ok() { + return Cred::ssh_key_from_agent("git"); + } let username = std::env::var("GIT_USERNAME").expect("GIT_USERNAME to be set"); let password = std::env::var("GIT_PASSWORD").expect("GIT_PASSWORD to be set"); Cred::userpass_plaintext(&username, &password) @@ -116,6 +119,9 @@ async fn main() -> eyre::Result<()> { let mut remote = repo.find_remote("origin")?; let mut cb = RemoteCallbacks::new(); cb.credentials(|_, _, _| { + if let Some(sock) = std::env::var("SSH_AUTH_SOCK").ok() { + return Cred::ssh_key_from_agent("git"); + } let username = std::env::var("GIT_USERNAME").expect("GIT_USERNAME to be set"); let password = std::env::var("GIT_PASSWORD").expect("GIT_PASSWORD to be set"); Cred::userpass_plaintext(&username, &password)