feat: with username

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-11-27 22:12:48 +01:00
parent 91c73c7a4e
commit 54524e46ae
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -40,9 +40,9 @@ async fn main() -> eyre::Result<()> {
);
let mut cb = RemoteCallbacks::new();
cb.credentials(|_, _, _| {
cb.credentials(|_, username, _| {
if let Some(sock) = std::env::var("SSH_AUTH_SOCK").ok() {
return Cred::ssh_key_from_agent("git");
return Cred::ssh_key_from_agent(username.unwrap_or("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");
@ -118,9 +118,9 @@ async fn main() -> eyre::Result<()> {
let mut remote = repo.find_remote("origin")?;
let mut cb = RemoteCallbacks::new();
cb.credentials(|_, _, _| {
cb.credentials(|_, username, _| {
if let Some(sock) = std::env::var("SSH_AUTH_SOCK").ok() {
return Cred::ssh_key_from_agent("git");
return Cred::ssh_key_from_agent(username.unwrap_or("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");