diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-10-25 01:27:42 -0400 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-10-25 01:27:42 -0400 |
| commit | f854e9757704eafaeb9e9847fbadff7d7b23e2a4 (patch) | |
| tree | f8552baec6294df2cc190a4dcf6681c9c29d486e /src/atom/parsers.rs | |
| parent | 680ead0504da6e0d78fb5bf499bff5160ef84970 (diff) | |
| download | gentoo-utils-f854e9757704eafaeb9e9847fbadff7d7b23e2a4.tar.gz | |
support atoms with wildcard versions
Diffstat (limited to 'src/atom/parsers.rs')
| -rw-r--r-- | src/atom/parsers.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs index 8026dfe..16e8fb1 100644 --- a/src/atom/parsers.rs +++ b/src/atom/parsers.rs @@ -28,7 +28,10 @@ pub fn version_operator<'a>() -> impl Parser<&'a str, Output = VersionOperator> } pub fn version_number<'a>() -> impl Parser<&'a str, Output = VersionNumber> { - numeric1().map(|output: &str| VersionNumber(output.to_string())) + numeric1() + .followed_by(opt(tag("*"))) + .recognize() + .map(|output: &str| VersionNumber(output.to_string())) } pub fn version_suffix_kind<'a>() -> impl Parser<&'a str, Output = VersionSuffixKind> { @@ -218,7 +221,15 @@ pub fn atom<'a>() -> impl Parser<&'a str, Output = Atom> { }, ) .verify_output(|atom| match (&atom.version_operator, &atom.version) { - (Some(_), Some(_)) => true, + (Some(VersionOperator::Eq), Some(_)) => true, + (Some(_), Some(version)) + if !version + .numbers() + .iter() + .any(|number| number.get().contains("*")) => + { + true + } (None, None) => true, _ => false, }) @@ -323,4 +334,18 @@ mod test { atom().check_finished(it).unwrap(); } + + #[test] + fn test_atom_with_star_in_version() { + let it = InputIter::new("=foo/bar-1.2*"); + + atom().check_finished(it).unwrap(); + } + + #[test] + fn test_atom_with_star_in_version_without_eq_version_operator() { + let it = InputIter::new(">=foo/bar-1.2*"); + + assert!(atom().check_finished(it).is_err()); + } } |
