Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle/git: Remove unused `fn remote_refs`
Lorenz Leutgeb committed 1 month ago
commit e78d477bcf78be33188947da912935976ba28fb9
parent 759a6fb
2 files changed +0 -52
modified 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<RandomMap<RemoteId, Refs>, 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::<PublicKey>(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.
modified crates/radicle/src/storage/git.rs
@@ -1065,32 +1065,6 @@ mod tests {
    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<Verified>)| (id, r.refs.into())))
-
            .collect::<Result<_, _>>()
-
            .unwrap();
-

-
        assert_eq!(refs, remotes);
-
    }
-

-
    #[test]
    fn test_references_of() {
        let tmp = tempfile::tempdir().unwrap();
        let signer = Device::mock();