Skip to content

Commit

Permalink
adapt to changes in gix
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jun 12, 2023
1 parent 6f9d32e commit 4bed38f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
10 changes: 4 additions & 6 deletions gitoxide-core/src/repository/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,20 @@ 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)
.expect("one origin remote")?;
let ref_specs = remote.refspecs(gix::remote::Direction::Fetch);
print_updates(
&repo,
negotiation_rounds,
negotiate,
update_refs,
ref_specs,
fetch_outcome.ref_map,
Expand Down
30 changes: 11 additions & 19 deletions gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}
Expand All @@ -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,
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit 4bed38f

Please sign in to comment.