radicle/git: Remove unused `fn remote_refs`
This commit is contained in:
parent
759a6fb982
commit
e78d477bcf
|
|
@ -10,11 +10,9 @@ pub use radicle_oid::{str::ParseOidError, Oid};
|
||||||
|
|
||||||
pub extern crate radicle_git_ref_format as fmt;
|
pub extern crate radicle_git_ref_format as fmt;
|
||||||
|
|
||||||
use crate::collections::RandomMap;
|
|
||||||
use crate::crypto::PublicKey;
|
use crate::crypto::PublicKey;
|
||||||
use crate::node::Alias;
|
use crate::node::Alias;
|
||||||
use crate::rad;
|
use crate::rad;
|
||||||
use crate::storage::refs::Refs;
|
|
||||||
use crate::storage::RemoteId;
|
use crate::storage::RemoteId;
|
||||||
|
|
||||||
pub use crate::storage::git::transport::local::Url;
|
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
|
/// Parse a [`fmt::Qualified`] reference string while expecting the reference
|
||||||
/// to start with `refs/namespaces`. If the namespace is not present, then an
|
/// to start with `refs/namespaces`. If the namespace is not present, then an
|
||||||
/// error will be returned.
|
/// error will be returned.
|
||||||
|
|
|
||||||
|
|
@ -1064,32 +1064,6 @@ mod tests {
|
||||||
use crate::storage::{ReadRepository, ReadStorage};
|
use crate::storage::{ReadRepository, ReadStorage};
|
||||||
use crate::test::fixtures;
|
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]
|
#[test]
|
||||||
fn test_references_of() {
|
fn test_references_of() {
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue