From 24125936adb6c152cdb16d55f2639dd374dfee1d Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 1 Aug 2024 10:17:01 +0100 Subject: feat(remote): `push` to all `clone` servers initially we push to the first server, if successful update the state event, then siliently push to the others and silently fail --- src/git_remote_helper.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/git_remote_helper.rs') diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index de49275..d0c0005 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs @@ -270,6 +270,24 @@ async fn push( ) .await?; + // silently push to any other git servers + for (i, git_server_url) in repo_ref.git_server.iter().enumerate() { + // we have already pushed to the first one + if i.gt(&0) { + if let Ok(mut git_server_remote) = git_repo.git_repo.remote_anonymous(git_server_url) { + let auth = GitAuthenticator::default(); + 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); + let _ = git_server_remote.push(&refspecs, Some(&mut push_options)); + let _ = git_server_remote.disconnect(); + } + } + } + // todo report on errors + println!(); Ok(()) } -- cgit v1.2.3