From d4b8d3d09eff3657c95c530909c80824dd084bde Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Wed, 1 Jan 2025 17:52:15 -0500 Subject: [PATCH 1/2] fix range ^0 h/t @mxcl --- lib/src/range/parse.rs | 10 ++++++++++ lib/src/tests/range.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/src/range/parse.rs b/lib/src/range/parse.rs index ac7240c..f160ce4 100644 --- a/lib/src/range/parse.rs +++ b/lib/src/range/parse.rs @@ -47,7 +47,17 @@ impl Constraint { return Ok(Constraint::Contiguous(v1, v2)); } + // ^0 is a special case, in that it doesn't work like + // ^0.x or ^0.x.y, but rather like any other ^x + if constraint == "^0" { + return Ok(Constraint::Contiguous( + Semver::parse("0.0.0")?, + Semver::parse("1.0.0")?, + )); + } + let re = Regex::new(r"^([~=<^])(.+)$")?; + if let Some(cap) = re.captures(constraint) { return match cap.get(1).context("invalid character")?.as_str() { "^" => { diff --git a/lib/src/tests/range.rs b/lib/src/tests/range.rs index 128e432..4fa90d3 100644 --- a/lib/src/tests/range.rs +++ b/lib/src/tests/range.rs @@ -90,6 +90,16 @@ fn test_satisfies() -> Result<()> { assert!(rg.satisfies(&sg)); assert!(!rg.satisfies(&sh)); + let ri = Range::parse("^0")?; + + let si = Semver::parse("0.0.5")?; + let sj = Semver::parse("0.21.1")?; + let sk = Semver::parse("1.0.0")?; + + assert!(ri.satisfies(&si)); + assert!(ri.satisfies(&sj)); + assert!(!ri.satisfies(&sk)); + Ok(()) } From f6b79514f547d4e54f9d7a2e34fe2935f40341ee Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Wed, 1 Jan 2025 17:57:09 -0500 Subject: [PATCH 2/2] bump version to 0.7.0 --- Cargo.lock | 4 ++-- cli/Cargo.toml | 4 ++-- lib/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b09a287..d1e570e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,7 +107,7 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "libsemverator" -version = "0.6.0" +version = "0.7.0" dependencies = [ "anyhow", "regex", @@ -150,7 +150,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "semverator" -version = "0.6.0" +version = "0.7.0" dependencies = [ "anyhow", "clap", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 96d8a4e..4ed710e 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "semverator" -version = "0.6.0" +version = "0.7.0" edition = "2021" license = "Apache-2.0" readme = "../README.md" @@ -13,7 +13,7 @@ categories = ["command-line-utilities"] [dependencies] anyhow = "1.0.75" clap = { version = '4.4.2', features = ['cargo'] } -libsemverator = { path = "../lib", version = "0.6.0" } +libsemverator = { path = "../lib", version = "0.7.0" } [lints.rust] unexpected_cfgs = { level = "allow", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 8b47781..8773974 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libsemverator" -version = "0.6.0" +version = "0.7.0" edition = "2021" license = "Apache-2.0" readme = "../README.md"