Skip to content

Commit

Permalink
adapt to changes in gix-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 31, 2023
1 parent 0de7117 commit df81076
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
22 changes: 20 additions & 2 deletions gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;

pub(crate) mod function {
use anyhow::bail;
use gix::remote::fetch::refs::update::TypeChange;
use gix::{prelude::ObjectIdExt, refspec::match_group::validate::Fix, remote::fetch::Status};
use layout::{
backends::svg::SVGWriter,
Expand Down Expand Up @@ -261,11 +262,28 @@ pub(crate) mod function {
crate::repository::remote::refs::print_ref(&mut out, r)?;
}
};
let mode_and_type = update.type_change.map_or_else(
|| format!("{}", update.mode),
|type_change| {
format!(
"{} ({})",
update.mode,
match type_change {
TypeChange::DirectToSymbolic => {
"direct ref overwrites symbolic"
}
TypeChange::SymbolicToDirect => {
"symbolic ref overwrites direct"
}
}
)
},
);
match edit {
Some(edit) => {
writeln!(out, " -> {} [{}]", edit.name, update.mode)
writeln!(out, " -> {} [{mode_and_type}]", edit.name)
}
None => writeln!(out, " [{}]", update.mode),
None => writeln!(out, " [{mode_and_type}]"),
}?;
}
consume_skipped_tags(&mut skipped_due_to_implicit_tag, &mut out)?;
Expand Down
12 changes: 11 additions & 1 deletion gitoxide-core/src/repository/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ mod refs_impl {
},
Symbolic {
path: String,
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
tag: Option<String>,
target: String,
object: String,
},
Expand All @@ -265,10 +267,12 @@ mod refs_impl {
},
handshake::Ref::Symbolic {
full_ref_name: path,
tag,
target,
object,
} => JsonRef::Symbolic {
path: path.to_string(),
tag: tag.map(|t| t.to_string()),
target: target.to_string(),
object: object.to_string(),
},
Expand Down Expand Up @@ -298,9 +302,15 @@ mod refs_impl {
} => write!(&mut out, "{tag} {path} object:{object}").map(|_| tag.as_ref()),
handshake::Ref::Symbolic {
full_ref_name: path,
tag,
target,
object,
} => write!(&mut out, "{object} {path} symref-target:{target}").map(|_| object.as_ref()),
} => match tag {
Some(tag) => {
write!(&mut out, "{tag} {path} symref-target:{target} peeled:{object}").map(|_| tag.as_ref())
}
None => write!(&mut out, "{object} {path} symref-target:{target}").map(|_| object.as_ref()),
},
handshake::Ref::Unborn { full_ref_name, target } => {
static NULL: gix::hash::ObjectId = gix::hash::ObjectId::null(gix::hash::Kind::Sha1);
write!(&mut out, "unborn {full_ref_name} symref-target:{target}").map(|_| NULL.as_ref())
Expand Down
1 change: 1 addition & 0 deletions gix/src/clone/fetch/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub fn update_head(
gix_protocol::handshake::Ref::Symbolic {
full_ref_name,
target,
tag: _,
object,
} if full_ref_name == "HEAD" => (Some(object.as_ref()), Some(target)),
gix_protocol::handshake::Ref::Direct { full_ref_name, object } if full_ref_name == "HEAD" => {
Expand Down
13 changes: 8 additions & 5 deletions gix/src/remote/connection/fetch/update_refs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,14 @@ mod update {
},
TargetRef::Symbolic(name) => {
let target = name.as_bstr().into();
let id = r.peel_to_id_in_place().unwrap();
gix_protocol::handshake::Ref::Symbolic {
full_ref_name,
target,
object: id.detach(),
match r.peel_to_id_in_place() {
Ok(id) => gix_protocol::handshake::Ref::Symbolic {
full_ref_name,
target,
tag: None,
object: id.detach(),
},
Err(_) => gix_protocol::handshake::Ref::Unborn { full_ref_name, target },
}
}
}
Expand Down

0 comments on commit df81076

Please sign in to comment.