Skip to content

Commit 1bccc54

Browse files
committed
Add a way to match refspecs with full globs support
1 parent 0d5372d commit 1bccc54

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-refspec/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ doctest = false
1818
gix-revision = { version = "^0.36.0", path = "../gix-revision", default-features = false }
1919
gix-validate = { version = "^0.10.1", path = "../gix-validate" }
2020
gix-hash = { version = "^0.20.0", path = "../gix-hash" }
21+
gix-glob = { version = "^0.22.1", path = "../gix-glob" }
2122

2223
bstr = { version = "1.12.0", default-features = false, features = ["std"] }
2324
thiserror = "2.0.17"

gix-refspec/src/match_group/util.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use gix_hash::ObjectId;
66
use crate::{match_group::Item, RefSpecRef};
77

88
/// A type keeping enough information about a ref-spec to be able to efficiently match it against multiple matcher items.
9+
#[derive(Debug)]
910
pub struct Matcher<'a> {
1011
pub(crate) lhs: Option<Needle<'a>>,
1112
pub(crate) rhs: Option<Needle<'a>>,
@@ -46,6 +47,7 @@ pub(crate) enum Needle<'a> {
4647
FullName(&'a BStr),
4748
PartialName(&'a BStr),
4849
Glob { name: &'a BStr, asterisk_pos: usize },
50+
Pattern(&'a BStr),
4951
Object(ObjectId),
5052
}
5153

@@ -168,9 +170,15 @@ impl<'a> From<&'a BStr> for Needle<'a> {
168170

169171
impl<'a> From<RefSpecRef<'a>> for Matcher<'a> {
170172
fn from(v: RefSpecRef<'a>) -> Self {
171-
Matcher {
173+
let mut m = Matcher {
172174
lhs: v.src.map(Into::into),
173175
rhs: v.dst.map(Into::into),
176+
};
177+
if m.rhs.is_none() {
178+
if let Some(src) = v.src {
179+
m.lhs = Some(Needle::Pattern(src))
180+
}
174181
}
182+
m
175183
}
176184
}

0 commit comments

Comments
 (0)