From 91e4b611120b4120703e7c8db1296274573da445 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 18:51:15 +0900 Subject: 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 --- crates/mozart-semver/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/mozart-semver/src') 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 { 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")); } -- cgit v1.3.1