From f2e674b5b90f891bd56247d370b047c7c81d33e3 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Sun, 28 Jul 2024 11:31:06 +0100 Subject: refactor(remote): allow more `push` callbacks by using GitAuthenticatior credential callback directly rather than its `push` method --- src/git_remote_helper.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/git_remote_helper.rs') diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index e6991d6..6e8f70f 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs @@ -99,9 +99,13 @@ async fn main() -> Result<()> { println!(); } ["push", refspec] => { - // Why are new branches being pushed without -u? let auth = GitAuthenticator::default(); - auth.push(&git_repo.git_repo, &mut temp_remote, &[refspec])?; + let git_config = git_repo.git_repo.config()?; + let mut push_options = git2::PushOptions::new(); + let mut remote_callbacks = git2::RemoteCallbacks::new(); + remote_callbacks.credentials(auth.credentials(&git_config)); + push_options.remote_callbacks(remote_callbacks); + temp_remote.push(&[refspec], Some(&mut push_options))?; update_remote_refs_from_push_refspecs(&git_repo.git_repo, refspec, url)?; temp_remote.disconnect()?; println!(); -- cgit v1.2.3