Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW
✗ CI failure Fintan Halpenny committed 7 months ago
commit cc99c8cc509107757916307fdc5f29210ef70114
parent 2ebef84cbb0f66c03e4ba3ae37e324dfe837683e
1 failed 1 pending (2 total) View logs
3 files changed +11 -6
modified crates/radicle/src/git/canonical/protect.rs
@@ -1,5 +1,8 @@
//! Some reference names are protected and cannot be used with canonical
//! references. This module contains checks for these cases.
+
//!
+
//! The current references that are protected:
+
//!   - Any references under `refs/rad`

static REFS_RAD: &str = "refs/rad";

@@ -79,9 +82,11 @@ mod common {
    }

    impl Unprotected<QualifiedPattern<'_>> {
-
        /// Construct a qualified reference name pattern that matches a branch
-
        /// exactly, i.e., return `/refs/heads/<name>`.
-
        pub fn branch_exact(name: &RefStr) -> Self {
+
        /// Construct a [`Unprotected`] pattern that matches a branch exactly.
+
        ///
+
        /// The resulting [`Unprotected`] pattern will match
+
        /// `refs/heads/<name>`.
+
        pub fn refs_heads_exact(name: &RefStr) -> Self {
            Self::new(QualifiedPattern::from(branch(name))).expect("branches are never protected")
        }
    }
modified crates/radicle/src/git/canonical/rules.rs
@@ -355,11 +355,11 @@ impl ValidRule {
    /// }
    /// ```
    ///
-
    /// # Errors
+
    /// # Panics
    ///
    /// If the `name` reference is protected (see [`crate::git::canonical::protect`]).
    pub fn default_branch(did: Did, name: &git::RefStr) -> (Pattern, Self) {
-
        let pattern = Pattern::branch_exact(name);
+
        let pattern = Pattern::refs_heads_exact(name);
        let rule = Self {
            allow: ResolvedDelegates::Delegates(doc::Delegates::from(did)),
            // N.B. this needs to be the minimum since we only have one
modified crates/radicle/src/identity/doc.rs
@@ -764,7 +764,7 @@ impl Doc {
    pub fn default_branch_rule(
        &self,
    ) -> Result<(rules::Pattern, rules::ValidRule), DefaultBranchError> {
-
        let pattern = rules::Pattern::branch_exact(self.project()?.default_branch());
+
        let pattern = rules::Pattern::refs_heads_exact(self.project()?.default_branch());
        let rule = rules::Rule::new(
            rules::ResolvedDelegates::Delegates(self.delegates.clone()),
            self.threshold,