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

Conversation

caspermeijn
Copy link
Contributor

@caspermeijn caspermeijn commented May 24, 2024

When a version range with a '<' character is found, the range is updated to the (latest version + 1). However for a range using "<=" this is invalid. Add a special case for a range using Less Than Equal which is updated to simply the latest version.

@@ -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?("<=")
version_class.new(target_version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version_class.new(target_version)
target_version

This branch is returning a Cargo::Version instance, which will be converted to a string with #to_s, which just outputs the version string it was initialized with, so I think this could be simplified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Fixed.

@@ -151,17 +151,34 @@
end

context "when there were multiple range specifications" do
let(:req_string) { "> 1.0.0, < 1.2.0" }
its([:requirement]) { is_expected.to eq("> 1.0.0, < 1.6.0") }
context "with `less then`" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking/nitpick: technically less than

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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") }
context "with `less then equal`" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking/nitpick: technically less than or equal to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

When a version range with a '<' character is found, the range is updated to the (latest version + 1). However for a range using "<=" this is invalid. Add a special case for a range using Less Than Equal which is updated to simply the latest version.
@caspermeijn caspermeijn force-pushed the cargo_version_range_lte branch from 2f03293 to 72f1102 Compare May 27, 2024 07:34
@caspermeijn caspermeijn changed the title fix(cargo): handle version range using Less Then Equal fix(cargo): handle version range using Less Than Equal May 27, 2024
@caspermeijn
Copy link
Contributor Author

I fixed all comments and resolved the merge conflict.

@sachin-sandhu sachin-sandhu merged commit c25bc8d into dependabot:main May 28, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: rust:cargo Rust crates via cargo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants