diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-01 10:17:01 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-08-01 10:19:36 +0100 |
| commit | 24125936adb6c152cdb16d55f2639dd374dfee1d (patch) | |
| tree | 3e3c2005b05c24dc31291cdad874a1cf1af1436d /src/git_remote_helper.rs | |
| parent | 1f38d2a97e4c8b1d814c414343d1e118ce119f70 (diff) | |
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
Diffstat (limited to 'src/git_remote_helper.rs')
| -rw-r--r-- | src/git_remote_helper.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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( | |||
| 270 | ) | 270 | ) |
| 271 | .await?; | 271 | .await?; |
| 272 | 272 | ||
| 273 | // silently push to any other git servers | ||
| 274 | for (i, git_server_url) in repo_ref.git_server.iter().enumerate() { | ||
| 275 | // we have already pushed to the first one | ||
| 276 | if i.gt(&0) { | ||
| 277 | if let Ok(mut git_server_remote) = git_repo.git_repo.remote_anonymous(git_server_url) { | ||
| 278 | let auth = GitAuthenticator::default(); | ||
| 279 | let git_config = git_repo.git_repo.config()?; | ||
| 280 | let mut push_options = git2::PushOptions::new(); | ||
| 281 | let mut remote_callbacks = git2::RemoteCallbacks::new(); | ||
| 282 | remote_callbacks.credentials(auth.credentials(&git_config)); | ||
| 283 | push_options.remote_callbacks(remote_callbacks); | ||
| 284 | let _ = git_server_remote.push(&refspecs, Some(&mut push_options)); | ||
| 285 | let _ = git_server_remote.disconnect(); | ||
| 286 | } | ||
| 287 | } | ||
| 288 | } | ||
| 289 | // todo report on errors | ||
| 290 | |||
| 273 | println!(); | 291 | println!(); |
| 274 | Ok(()) | 292 | Ok(()) |
| 275 | } | 293 | } |