diff --git a/crates/radicle/src/git.rs b/crates/radicle/src/git.rs index 3a9c2d18..1c0e1fe4 100644 --- a/crates/radicle/src/git.rs +++ b/crates/radicle/src/git.rs @@ -10,11 +10,9 @@ pub use radicle_oid::{str::ParseOidError, Oid}; pub extern crate radicle_git_ref_format as fmt; -use crate::collections::RandomMap; use crate::crypto::PublicKey; use crate::node::Alias; use crate::rad; -use crate::storage::refs::Refs; use crate::storage::RemoteId; pub use crate::storage::git::transport::local::Url; @@ -449,30 +447,6 @@ pub mod refs { } } -/// List remote refs of a project, given the remote URL. -pub fn remote_refs(url: &Url) -> Result, ListRefsError> { - let url = url.to_string(); - let mut remotes = RandomMap::default(); - let mut remote = raw::Remote::create_detached(url)?; - - remote.connect(raw::Direction::Fetch)?; - - let refs = remote.list()?; - for r in refs { - // Skip the `HEAD` reference, as it is untrusted. - if r.name() == "HEAD" { - continue; - } - // Nb. skip refs that don't have a public key namespace. - if let (Some(id), refname) = parse_ref::(r.name())? { - let entry = remotes.entry(id).or_insert_with(Refs::default); - entry.insert(refname.into(), r.oid().into()); - } - } - - Ok(remotes) -} - /// Parse a [`fmt::Qualified`] reference string while expecting the reference /// to start with `refs/namespaces`. If the namespace is not present, then an /// error will be returned. diff --git a/crates/radicle/src/storage/git.rs b/crates/radicle/src/storage/git.rs index ad655fbe..2b0c5582 100644 --- a/crates/radicle/src/storage/git.rs +++ b/crates/radicle/src/storage/git.rs @@ -1064,32 +1064,6 @@ mod tests { use crate::storage::{ReadRepository, ReadStorage}; use crate::test::fixtures; - #[test] - fn test_remote_refs() { - let dir = tempfile::tempdir().unwrap(); - let signer = Device::mock(); - let storage = fixtures::storage(dir.path(), &signer).unwrap(); - let inv = storage.repositories().unwrap(); - let proj = inv.first().unwrap(); - let mut refs = git::remote_refs(&git::Url::from(proj.rid)).unwrap(); - - let project = storage.repository(proj.rid).unwrap(); - let remotes = project.remotes().unwrap(); - - // Strip the remote refs of sigrefs so we can compare them. - for remote in refs.values_mut() { - let sigref = (*SIGREFS_BRANCH).to_ref_string(); - remote.remove(&sigref).unwrap(); - } - - let remotes = remotes - .map(|remote| remote.map(|(id, r): (RemoteId, Remote)| (id, r.refs.into()))) - .collect::>() - .unwrap(); - - assert_eq!(refs, remotes); - } - #[test] fn test_references_of() { let tmp = tempfile::tempdir().unwrap();