From 4bed38fc000e01dcf1c47cd1b4c63e4e79bc51f7 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Jun 2023 16:40:28 +0200 Subject: [PATCH] adapt to changes in `gix` --- gitoxide-core/src/repository/clone.rs | 10 ++++----- gitoxide-core/src/repository/fetch.rs | 30 ++++++++++----------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/gitoxide-core/src/repository/clone.rs b/gitoxide-core/src/repository/clone.rs index 3a29fd7138f..e81cb6170d0 100644 --- a/gitoxide-core/src/repository/clone.rs +++ b/gitoxide-core/src/repository/clone.rs @@ -88,14 +88,12 @@ pub(crate) mod function { } match fetch_outcome.status { - Status::NoPackReceived { .. } => { + Status::NoPackReceived { dry_run, .. } => { + assert!(!dry_run, "dry-run unsupported"); writeln!(err, "The cloned repository appears to be empty")?; } - Status::DryRun { .. } => unreachable!("dry-run unsupported"), Status::Change { - update_refs, - negotiation_rounds, - .. + update_refs, negotiate, .. } => { let remote = repo .find_default_remote(gix::remote::Direction::Fetch) @@ -103,7 +101,7 @@ pub(crate) mod function { let ref_specs = remote.refspecs(gix::remote::Direction::Fetch); print_updates( &repo, - negotiation_rounds, + negotiate, update_refs, ref_specs, fetch_outcome.ref_map, diff --git a/gitoxide-core/src/repository/fetch.rs b/gitoxide-core/src/repository/fetch.rs index d2139b9415e..df7ac1c9b66 100644 --- a/gitoxide-core/src/repository/fetch.rs +++ b/gitoxide-core/src/repository/fetch.rs @@ -62,15 +62,13 @@ pub(crate) mod function { let ref_specs = remote.refspecs(gix::remote::Direction::Fetch); match res.status { - Status::NoPackReceived { update_refs } => { - print_updates(&repo, 1, update_refs, ref_specs, res.ref_map, &mut out, err) - } - Status::DryRun { + Status::NoPackReceived { update_refs, - negotiation_rounds, + negotiate, + dry_run: _, } => print_updates( &repo, - negotiation_rounds, + negotiate.unwrap_or_default(), update_refs, ref_specs, res.ref_map, @@ -80,17 +78,9 @@ pub(crate) mod function { Status::Change { update_refs, write_pack_bundle, - negotiation_rounds, + negotiate, } => { - print_updates( - &repo, - negotiation_rounds, - update_refs, - ref_specs, - res.ref_map, - &mut out, - err, - )?; + print_updates(&repo, negotiate, update_refs, ref_specs, res.ref_map, &mut out, err)?; if let Some(data_path) = write_pack_bundle.data_path { writeln!(out, "pack file: \"{}\"", data_path.display()).ok(); } @@ -108,7 +98,7 @@ pub(crate) mod function { pub(crate) fn print_updates( repo: &gix::Repository, - negotiation_rounds: usize, + negotiate: gix::remote::fetch::outcome::Negotiate, update_refs: gix::remote::fetch::refs::update::Outcome, refspecs: &[gix::refspec::RefSpec], mut map: gix::remote::fetch::RefMap, @@ -212,8 +202,10 @@ pub(crate) mod function { refspecs.len() )?; } - if negotiation_rounds != 1 { - writeln!(err, "needed {negotiation_rounds} rounds of pack-negotiation")?; + match negotiate.rounds.len() { + 0 => writeln!(err, "no negotiation was necessary")?, + 1 => {} + rounds => writeln!(err, "needed {rounds} rounds of pack-negotiation")?, } Ok(()) }