-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(ruby): extract version with quotation #17222
Conversation
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've a simpler solution
I've looked again in code and it seems we should always extract with quotes, so that the folling will also add them renovate/lib/modules/versioning/ruby/index.ts Lines 147 to 162 in a3c8e20
|
That is precisely what the original commit 347d4a1 intends to do. So I'm going to revert the later commits. |
Reverted to the original commit, but there is one thing to note: If we let the versioning module handle quotes, the quotes appear in the PR title: Otherwise, if we handle quotes in the manager, the quotes are not shown. I do not mind the quotes appearing in the title, but I'm willing to revert back to the other implementation again if the quotes are undesirable. |
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.
handling in versioning is the easier solution for now
🎉 This PR is included in version 32.165.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes
This is an attempt to fix a problem introduced in #17091.
In the
bump
strategy, the Ruby versioning sometimes tries to add a>=
constraint to the existing~>
constraint, but it fails.I guess Renovate is failing in the following way:
Ruby versioning module preserves quotations:
~> 2.3
may be updated to~> 3.0
or~> 3.0, >= 3.0.1
'~> 2.3'
may be updated to'~> 3.0'
or'~> 3.0', '>= 3.0.1'
>= 1.0, < 2.0
may be updated to>= 2.0, < 3.0
'>= 1.0', '< 2.0'
may be updated to'>= 2.0', '< 3.0'
Bundler manager retains quotations only if there are multiple constraints:
gem 'rails', '~> 6.1'
,~> 6.1
will be extracted.gem 'rails', '~> 6.1', '>= 6.1.2'
,'~> 6.1', '>= 6.1.2'
will be extracted.Therefore, if there was only one constraint, it will replace the content in the quotation. If the versioning module decides to add another constraint, it will be added within the quotation:
This is not what Bundler expects and the update fails.
This PR tries to fix the issue by changing the Bundler's side by always including quotation marks when extracting versions, but I'm not sure this is an optimal solution. Other possible solutions are:Try to modify the source code after changing the version in Gemfile.Change the ruby versioning module so that quotation marks are necessary.Pass certain metadata from the Bundler manager to the ruby versioning module to request quotation marks.Separate the ruby versioning module into two: one that supports only a single ruby range and one that supports multiple quoted ranges.Per comment #17222 (comment) , it is now Bundler manager's job to add/remove quotes in appropriate places. This is done by adding
updateDependency
function to the manager.Context
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: