summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarshal Bhakta <harshal.c.bhakta@gmail.com>2023-09-29 15:42:16 +0530
committergit <svn-admin@ruby-lang.org>2023-10-02 02:19:43 +0000
commitf208f78bdfc65341cb6547a378ff616b1928e48a (patch)
tree23090ae1c060b44dbd48cdbaaa59554e93639231 /lib
parentf3aea74c3d63a9b1e0f597b060bf84c14d1c70fc (diff)
[rubygems/rubygems] Support Ruby's preview version format (Ex: 3.3.0-preview2) in Gemfile
https://github.com/rubygems/rubygems/commit/4c1a0511b6
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/ruby_version.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index b5396abb6e..52868b5fb8 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -23,7 +23,7 @@ module Bundler
# specified must match the version.
@versions = Array(versions).map do |v|
- op, v = Gem::Requirement.parse(v)
+ op, v = Gem::Requirement.parse(normalize_version(v))
op == "=" ? v.to_s : "#{op} #{v}"
end
@@ -112,6 +112,13 @@ module Bundler
private
+ # Ruby's official preview version format uses a `-`: Example: 3.3.0-preview2
+ # However, RubyGems recognizes preview version format with a `.`: Example: 3.3.0.preview2
+ # Returns version string after replacing `-` with `.`
+ def normalize_version(version)
+ version.tr("-", ".")
+ end
+
def matches?(requirements, version)
# Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"