-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support single quotes in mise format ruby version #9183
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
Support single quotes in mise format ruby version #9183
Conversation
bundler/lib/bundler/ruby_dsl.rb
Outdated
| [^\s#"']+ # One or more chars that aren't spaces, #, or quotes | ||
| ) # End capturing group | ||
| "? # Optional closing quote | ||
| ["']? # Optional closing quote |
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.
Can we reject "3.2.2' (quote mismatch)?
The previous regex didn't properly match quoted strings it would capture the opening quote as part of the version if quotes were mismatched. This change properly parses double-quoted, single-quoted, and unquoted version strings separately.
| end | ||
|
|
||
| it "raises an error" do | ||
| expect { subject }.to raise_error(Bundler::InvalidArgumentError, "= is not a valid requirement on the Ruby version") |
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'm not sure if the error message = is not a valid requirement ... is appropriate.
If I add = to ([^\s#"']+) # Unquoted version to make it ([^\s#"'=]+), the error message would become [tools]\nruby = \"2.0.0' is not a valid requirement ..., which I feel is better than = is not a valid requirement.
However, I'm concerned this change to ([^\s#"'=]+) might introduce regressions.
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.
Let's not make any changes involving = at this time, as we don't yet fully support the mise format.
FYI: #8998
…ise-format Support single quotes in mise format ruby version (cherry picked from commit 6b618d9)
What was the end-user or developer problem that led to this PR?
mise.tomlsupports specifying Ruby versions using both double quotes (ruby = "3.2.2") and single quotes (ruby = '3.2.2'). However, Bundler'sruby file:directive only recognized double-quoted versions, causing single-quoted versions to fail parsing.What is your fix for the problem, implemented in this PR?
Updated the regular expression to accept both single quotes (
') and double quotes (") when parsing Ruby version files in mise format.Make sure the following tasks are checked