-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 prereleases not being considered by gem version promoter when there's no lockfile #6537
Fix prereleases not being considered by gem version promoter when there's no lockfile #6537
Conversation
Add tests for pre, move more of the setup into a helper method, and restructure tests. There seem to be five considerations for these tests (level, pre, strict, locked, and whether the current version is a prerelease version, though the last one overlaps with pre and didn't seem to behave how I expected under test). Rather than write out the 16 (/32 if the last consideration is real) combinations, I wrote most with independent tests for each value. The existing combined tests were maintained (level vs strict) because these seem the most interrelated.
Prereleases are NOT considered even when the dependency specification includes a prerelease segment, if the dependency is not locked. To me that doesn't make sense, because I could create a Gemfile with say gem "rails", ">= 7.0.0.beta1" and I'd expect prereleases considered there even if there's no lock file yet. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@deivid-rodriguez the tests are more or less the same commit from that original PR. I made sure all the cases are still covered, and fixed some new kwargs that have been added since. Re: your comment, I wonder whether the current behavior feeling surprising is due to how I worded some of the tests w.r.t. 'favors'. Ultimately, what the GemVersionPromoter returns is flipped (I believe here: rubygems/bundler/lib/bundler/resolver.rb Line 313 in 849342b
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome, thanks for following up on this!
Bundler::GemVersionPromoter.new.tap do |gvp| | ||
gvp.level = :minor | ||
gvp.strict = true | ||
it "keeps downgrades" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what was surprising to me. The other levels remove downgrades, but this one (the default), does not. I think this complicates things for Bundler outside of the gem version promoter because it needs to explicit add lower bound requirements to dependencies and I think it may be to workaround this.
Nothing to fix in this PR, but I think we may be able to remove a bit of complexity but making level=major
behave like the other levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha. Yeah that had tripped me up a couple times. I'm not currently at the computer, but I wonder if changing
return specs if locked_version.nil? || major? |
- return specs if locked_version.nil? || major?
+ return specs if locked_version.nil?
would fix that. Happy to try it either on this branch or a follow up!
Add gem version promoter specs (cherry picked from commit 3421ec3)
What was the end-user or developer problem that led to this PR?
Pulled out some spec changes as a result of #5258 (review) (
) and a bug fix mentioned in #5258 (comment).
What is your fix for the problem, implemented in this PR?
Spec changes
Add tests for pre, move more of the setup into a helper method, and restructure tests.
There seem to be five considerations for these tests (level, pre, strict, locked, and whether the current version is a prerelease version, though the last one overlaps with pre and didn't seem to behave how I expected under test). Rather than write out the 16 (/32 if the last consideration is real) combinations, I wrote most with independent tests for each value. The existing combined tests were maintained (level vs strict) because these seem the most interrelated.
Bug Fix
Make sure the following tasks are checked