Skip to content

Commit 2fb7fc1

Browse files
authored
fix: allow not starts with in strict mode (#577)
1 parent c1efff3 commit 2fb7fc1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

crates/rattler_conda_types/src/version_spec/constraint.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ mod test {
236236
Constraint::from_str("=1.2.*", Strict),
237237
Err(ParseConstraintError::GlobVersionIncompatibleWithOperator(_))
238238
);
239-
assert_matches!(
240-
Constraint::from_str("!=1.2.*", Strict),
241-
Err(ParseConstraintError::GlobVersionIncompatibleWithOperator(_))
239+
assert_eq!(
240+
Constraint::from_str("!=1.2.*", Lenient),
241+
Ok(Constraint::StrictComparison(
242+
StrictRangeOperator::NotStartsWith,
243+
Version::from_str("1.2").unwrap(),
244+
))
242245
);
243246
assert_matches!(
244247
Constraint::from_str(">=1.2.*", Strict),

crates/rattler_conda_types/src/version_spec/parse.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,13 @@ fn logical_constraint_parser(
210210
)),
211211
Lenient,
212212
) => VersionOperators::Range(RangeOperator::GreaterEquals),
213-
("*" | ".*", Some(VersionOperators::Exact(EqualityOperator::NotEquals)), Lenient) => {
213+
(
214+
"*" | ".*",
215+
Some(VersionOperators::Exact(EqualityOperator::NotEquals)),
216+
Lenient | Strict,
217+
) => {
218+
// !=1.2.3.* is the only way to express a version should not start with 1.2.3 so
219+
// even in strict mode we allow this.
214220
VersionOperators::StrictRange(StrictRangeOperator::NotStartsWith)
215221
}
216222
("*" | ".*", Some(op), Lenient) => {

0 commit comments

Comments
 (0)