diff --git a/crates/radicle-node/src/tests/e2e.rs b/crates/radicle-node/src/tests/e2e.rs index affcb6c02..246652222 100644 --- a/crates/radicle-node/src/tests/e2e.rs +++ b/crates/radicle-node/src/tests/e2e.rs @@ -1614,7 +1614,7 @@ fn missing_delegate_default_branch() { "Further investigation into delegates", ); let assert_bobs_issue_exists = |repo: &Repository| { - let issue_ref = radicle::git::refs::storage::cob( + let issue_ref = radicle::git::refs::storage::cob_with_namespace( bob.signer.public_key(), &radicle::cob::issue::TYPENAME, &issue, diff --git a/crates/radicle/src/cob/issue.rs b/crates/radicle/src/cob/issue.rs index b78606323..1a13a24ec 100644 --- a/crates/radicle/src/cob/issue.rs +++ b/crates/radicle/src/cob/issue.rs @@ -1475,7 +1475,8 @@ mod test { fn write_non_commit_cob_ref(repo: &storage::git::Repository, issue: &IssueId) { let mallory = SigningKey::mock(!1); let blob = repo.backend.blob(b"not a commit").unwrap(); - let name = crate::git::refs::storage::cob(mallory.public_key(), &TYPENAME, issue); + let name = + crate::git::refs::storage::cob_with_namespace(mallory.public_key(), &TYPENAME, issue); repo.backend .reference(name.as_str(), blob, true, "mallory") @@ -1544,7 +1545,8 @@ mod test { .unwrap(); let id = issue.id; - let own = crate::git::refs::storage::cob(node.signer.public_key(), &TYPENAME, &id); + let own = + crate::git::refs::storage::cob_with_namespace(node.signer.public_key(), &TYPENAME, &id); repo.backend .find_reference(own.as_str()) .unwrap() diff --git a/crates/radicle/src/cob/store.rs b/crates/radicle/src/cob/store.rs index 3a0fd102c..c14396e6e 100644 --- a/crates/radicle/src/cob/store.rs +++ b/crates/radicle/src/cob/store.rs @@ -355,7 +355,7 @@ where /// Remove an object. pub fn remove(&mut self, id: &ObjectId) -> Result<(), Error> { let namespace = self.access.signer.public_key(); - let name = git::refs::storage::cob(namespace, self.scope.type_name, id); + let name = git::refs::storage::cob_with_namespace(namespace, self.scope.type_name, id); match self.repo.reference_oid(namespace, &name.strip_namespace()) { Ok(_) => { cob::remove(self.repo, namespace, self.scope.type_name, id)?; diff --git a/crates/radicle/src/cob/stream.rs b/crates/radicle/src/cob/stream.rs index 0512c28d8..214e71960 100644 --- a/crates/radicle/src/cob/stream.rs +++ b/crates/radicle/src/cob/stream.rs @@ -69,7 +69,7 @@ impl CobRange { /// The range will be from the root, given by the [`ObjectId`], to the /// reference tips of all remote namespaces. pub fn new(typename: &TypeName, object_id: &ObjectId) -> Self { - let glob = crate::storage::refs::cobs(typename, object_id); + let glob = crate::storage::refs::cob(typename, object_id); Self { root: **object_id, until: iter::Until::Glob(glob), diff --git a/crates/radicle/src/git.rs b/crates/radicle/src/git.rs index 8537bc111..55760b11e 100644 --- a/crates/radicle/src/git.rs +++ b/crates/radicle/src/git.rs @@ -245,7 +245,7 @@ pub mod refs { /// /// `refs/namespaces//refs/cobs//` /// - pub fn cob<'a>( + pub fn cob_with_namespace<'a>( remote: &RemoteId, typename: &cob::TypeName, object_id: &cob::ObjectId, @@ -262,13 +262,24 @@ pub mod refs { /// /// `refs/namespaces/*/refs/cobs//` /// - pub fn cobs(typename: &cob::TypeName, object_id: &cob::ObjectId) -> refspec::PatternString { + pub fn cob(typename: &cob::TypeName, object_id: &cob::ObjectId) -> refspec::PatternString { pattern!("refs/namespaces/*") .join(refname!("refs/cobs")) .join(Component::from(typename)) .join(Component::from(object_id)) } + /// All collaborative objects, identified by `typename`, for all remotes. + /// + /// `refs/namespaces/*/refs/cobs//` + /// + pub fn cobs(typename: &cob::TypeName) -> refspec::PatternString { + pattern!("refs/namespaces/*") + .join(refname!("refs/cobs")) + .join(Component::from(typename)) + .join_pattern(refspec::STAR) + } + /// Draft references. /// /// These references are not replicated or signed. diff --git a/crates/radicle/src/identity/doc.rs b/crates/radicle/src/identity/doc.rs index 756a7a36e..c40a174c1 100644 --- a/crates/radicle/src/identity/doc.rs +++ b/crates/radicle/src/identity/doc.rs @@ -1061,7 +1061,11 @@ impl Doc { let cob = identity::Identity::initialize(self, repo, signer)?; let public_key = signer.public_key(); let id_ref = git::refs::storage::id(public_key); - let cob_ref = git::refs::storage::cob(public_key, &crate::cob::identity::TYPENAME, &cob.id); + let cob_ref = git::refs::storage::cob_with_namespace( + public_key, + &crate::cob::identity::TYPENAME, + &cob.id, + ); // Set `…/refs/rad/id` -> `…/refs/cobs/xyz.radicle.id/` repo.backend.reference_symbolic( id_ref.as_str(), diff --git a/crates/radicle/src/storage/git/cob.rs b/crates/radicle/src/storage/git/cob.rs index cf13099e7..ea64cd151 100644 --- a/crates/radicle/src/storage/git/cob.rs +++ b/crates/radicle/src/storage/git/cob.rs @@ -113,7 +113,7 @@ impl cob::object::Storage for Repository { object_id: &cob::ObjectId, ) -> Result { self.backend - .references_glob(git::refs::storage::cobs(typename, object_id).as_str())? + .references_glob(&git::refs::storage::cob(typename, object_id))? .try_fold(cob::object::Objects::default(), |mut objects, reference| { if let Some(reference) = cob_reference(reference?)? { objects.push(reference); @@ -173,7 +173,7 @@ impl cob::object::Storage for Repository { entry: &cob::EntryId, ) -> Result<(), Self::UpdateError> { self.backend.reference( - git::refs::storage::cob(namespace, typename, object_id).as_str(), + git::refs::storage::cob_with_namespace(namespace, typename, object_id).as_str(), (*entry).into(), true, &format!( @@ -190,9 +190,9 @@ impl cob::object::Storage for Repository { typename: &cob::TypeName, object_id: &cob::ObjectId, ) -> Result<(), Self::RemoveError> { - let mut reference = self - .backend - .find_reference(git::refs::storage::cob(namespace, typename, object_id).as_str())?; + let mut reference = self.backend.find_reference( + git::refs::storage::cob_with_namespace(namespace, typename, object_id).as_str(), + )?; reference.delete() } @@ -415,7 +415,7 @@ impl cob::object::Storage for DraftStore<'_, R> { // First get the signed COB tips of all remotes for this object. let signed = self .repo - .references_glob(&git::refs::storage::cobs(typename, object_id))?; + .references_glob(&git::refs::storage::cob(typename, object_id))?; for (r, id) in signed { let r = cob::object::Reference {