radicle: Allow all references to be included in sigrefs

Previously, the `references_of` implementation restricted the set of
references to certain categories: heads, tags, notes, rad, and cobs.

This is too restrictive to allow peers to share any references they
want. The only exceptions is references `refs/tmp/heads` that are
created for creating patches.
This commit is contained in:
Defelo 2026-01-13 14:45:57 +01:00 committed by Fintan Halpenny
parent 67dee65549
commit a4e66d141e
2 changed files with 22 additions and 13 deletions

View File

@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## New Features
- The set of references returned by `references_of` were restricted to `heads`,
`tags`, `notes`, `rad`, and `cobs`. The restriction is lifted, and the only
references filtered out are `refs/tmp/heads` used by `radicle-remote-helper`
to create temporary patches.
## Fixed Bugs
## Deprecations

View File

@ -739,6 +739,17 @@ impl ReadRepository for Repository {
.graph_descendant_of(head.into(), ancestor.into())
}
/// The published references of the given `remote`.
///
/// Note that this includes all references, including `refs/rad/sigrefs`.
/// This reference must be removed before signing the payload.
///
/// # Skipped References
///
/// References created by [`staging::patch`], i.e. references that begin
/// with `refs/tmp/heads`, are skipped.
///
/// [`staging::patch`]: crate::git::refs::storage::staging::patch
fn references_of(&self, remote: &RemoteId) -> Result<Refs, Error> {
let entries = self
.backend
@ -750,22 +761,15 @@ impl ReadRepository for Repository {
let name = e.name().ok_or(Error::InvalidRef)?;
let (_, refname) = git::parse_ref::<RemoteId>(name)?;
let oid = e.resolve()?.target().ok_or(Error::InvalidRef)?;
let (_, category, _, _) = refname.non_empty_components();
let (_, category, subcategory, _) = refname.non_empty_components();
use git::fmt::{component, name};
if [
name::HEADS,
name::TAGS,
name::NOTES,
&component!("rad"),
&component!("cobs"),
]
.contains(&category.as_ref())
{
match (category.as_str(), subcategory.as_str()) {
("tmp", "heads") => continue,
_ => {
refs.insert(refname.into(), oid.into());
}
}
}
Ok(refs.into())
}