Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cargo): handle version range using Less Than Equal #9828

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ def update_range_requirements(string_reqs)
raise UnfixableRequirement if req.start_with?(">")

req.sub(VERSION_REGEX) do |old_version|
update_greatest_version(old_version, target_version)
if req.start_with?("<=")
target_version
else
update_greatest_version(old_version, target_version)
end
end
end.join(", ")
rescue UnfixableRequirement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,40 @@
end

context "when there were multiple range specifications" do
let(:req_string) { "> 1.0.0, < 1.2.0" }
context "with `less than`" do
let(:req_string) { "> 1.0.0, < 1.2.0" }

its([:requirement]) { is_expected.to eq("> 1.0.0, < 1.6.0") }
its([:requirement]) { is_expected.to eq("> 1.0.0, < 1.6.0") }

context "when already valid" do
let(:req_string) { "> 1.0.0, < 1.7.0" }
context "when already valid" do
let(:req_string) { "> 1.0.0, < 1.7.0" }

its([:requirement]) { is_expected.to eq(req_string) }
its([:requirement]) { is_expected.to eq(req_string) }
end

context "when including a pre-release" do
let(:req_string) { ">=1.2.0, <1.4.0-dev" }

its([:requirement]) { is_expected.to eq(">=1.2.0, <1.6.0") }
end
end

context "when including a pre-release" do
let(:req_string) { ">=1.2.0, <1.4.0-dev" }
context "with `less than equal`" do
let(:req_string) { "> 1.0.0, <= 1.2.0" }

its([:requirement]) { is_expected.to eq(">=1.2.0, <1.6.0") }
its([:requirement]) { is_expected.to eq("> 1.0.0, <= 1.5.0") }

context "when already valid" do
let(:req_string) { "> 1.0.0, <= 1.7.0" }

its([:requirement]) { is_expected.to eq(req_string) }
end

context "when including a pre-release" do
let(:req_string) { ">=1.2.0, <=1.4.0-dev" }

its([:requirement]) { is_expected.to eq(">=1.2.0, <=1.5.0") }
end
end
end

Expand Down
Loading