aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-semver/src/lib.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-22 18:51:15 +0900
committernsfisis <nsfisis@gmail.com>2026-02-22 18:51:15 +0900
commit91e4b611120b4120703e7c8db1296274573da445 (patch)
tree59cab557288b235ad181c74167ae975861274816 /crates/mozart-semver/src/lib.rs
parentff0d51089d8c5abc9ecbdeeaf3d6aa152f137e97 (diff)
downloadphp-mozart-91e4b611120b4120703e7c8db1296274573da445.tar.gz
php-mozart-91e4b611120b4120703e7c8db1296274573da445.tar.zst
php-mozart-91e4b611120b4120703e7c8db1296274573da445.zip
feat(semver): support `==` (double equals) version constraint
Parse `==` as an exact match operator, identical to `=`. Previously the `=` handler would strip only one `=`, leaving `=1.2.3` which failed to parse as a version number. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-semver/src/lib.rs')
-rw-r--r--crates/mozart-semver/src/lib.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/mozart-semver/src/lib.rs b/crates/mozart-semver/src/lib.rs
index 5a09cfe..6377785 100644
--- a/crates/mozart-semver/src/lib.rs
+++ b/crates/mozart-semver/src/lib.rs
@@ -552,6 +552,11 @@ fn parse_single(s: &str) -> Result<VersionConstraint, String> {
let v = Version::parse_for_constraint(rest.trim())?;
return Ok(VersionConstraint::Single(Constraint::NotEqual(v)));
}
+ // Double-equals `==` is treated the same as `=` (exact match)
+ if let Some(rest) = s.strip_prefix("==") {
+ let v = Version::parse_for_constraint(rest.trim())?;
+ return Ok(VersionConstraint::Single(Constraint::Exact(v)));
+ }
if let Some(rest) = s.strip_prefix('>') {
let v = Version::parse_for_constraint(rest.trim())?;
return Ok(VersionConstraint::Single(Constraint::GreaterThan(v)));
@@ -1528,12 +1533,8 @@ mod tests {
}
#[test]
- #[ignore = "== (double equals) is not supported: the '=' handler passes '=1.2.3' to \
- Version::parse_for_constraint which fails to parse '=1' as a major number"]
fn test_double_equals_sign() {
- // "==1.2.3" — the '=' branch strips one '=', leaving "=1.2.3", which is then
- // passed to Version::parse_for_constraint. That function tries to parse "=1" as
- // a major version number and fails. Double-equals is not a supported syntax.
+ // "==1.2.3" is treated the same as "=1.2.3" (exact match)
assert!(satisfies("==1.2.3", "1.2.3"));
assert!(!satisfies("==1.2.3", "1.2.4"));
}