Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle/crefs/rules: Exact patterns for branches
Lorenz Leutgeb committed 7 months ago
commit b7425da06cc20af24219c2b2e2fe9f1af1c3577b
parent 8df72286807a06acfb985c1dec5704ec0303dd0e
1 file changed +7 -0
modified crates/radicle/src/git/canonical/rules.rs
@@ -14,6 +14,7 @@ use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::sync::LazyLock;

+
use git_ext::ref_format::RefStr;
use nonempty::NonEmpty;
use serde::{Deserialize, Serialize};
use serde_json as json;
@@ -81,6 +82,12 @@ impl<'a> TryFrom<Qualified<'a>> for Pattern {
}

impl Pattern {
+
    /// Construct a pattern that matches a branch exactly, i.e. return
+
    /// `/refs/heads/<branch>`.
+
    pub fn exact(branch: &RefStr) -> Self {
+
        Self(QualifiedPattern::from(git::refs::branch(branch)))
+
    }
+

    /// Check if the `refname` matches the rule's `refspec`.
    pub fn matches(&self, refname: &Qualified) -> bool {
        // N.b. Git's refspecs do not quite match with glob-star semantics. A