mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-21 18:40:40 +08:00
git-ref-format: add QualifiedPattern and NamespacedPattern
There was no mechanism for building refspec patterns that included namespaces. To get around this limitation, QualifiedPattern and NamespacedPattern are added to the refspec module. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -9,7 +9,14 @@ use std::{
|
||||
ops::Deref,
|
||||
};
|
||||
|
||||
use crate::{lit, name, Component, RefStr, RefString};
|
||||
use crate::{
|
||||
lit,
|
||||
name,
|
||||
refspec::{PatternStr, QualifiedPattern},
|
||||
Component,
|
||||
RefStr,
|
||||
RefString,
|
||||
};
|
||||
|
||||
/// A fully-qualified refname.
|
||||
///
|
||||
@@ -74,6 +81,13 @@ impl<'a> Qualified<'a> {
|
||||
Qualified(self.0.join(other).into())
|
||||
}
|
||||
|
||||
pub fn to_pattern<P>(&self, pattern: P) -> QualifiedPattern
|
||||
where
|
||||
P: AsRef<PatternStr>,
|
||||
{
|
||||
QualifiedPattern(Cow::Owned(RefStr::to_pattern(self, pattern.as_ref())))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_namespaced(&self) -> Option<Namespaced> {
|
||||
self.0.as_ref().into()
|
||||
|
||||
Reference in New Issue
Block a user