[前][次][番号順一覧][スレッド一覧]

ruby-changes:70017

From: David <ko1@a...>
Date: Thu, 2 Dec 2021 18:10:48 +0900 (JST)
Subject: [ruby-changes:70017] 2a15b28a9e (master): [rubygems/rubygems] Fix materialization of locked 0 prereleases

https://git.ruby-lang.org/ruby.git/commit/?id=2a15b28a9e

From 2a15b28a9ec59d41fc3f9a5e17cf3efe6d0817b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Tue, 30 Nov 2021 18:03:14 +0100
Subject: [rubygems/rubygems] Fix materialization of locked 0 prereleases

Since the default requirement in rubygems is ">= 0", it was failing to
match 0 prereleases. Changing the default globally to be ">= 0.a"
instead is a major refactoring that's quite tricky to make backwards
compatible, so I'm special casing this where needed for now to fix the
regression.

https://github.com/rubygems/rubygems/commit/68fe37937c
---
 lib/bundler/lazy_specification.rb         |  4 +++-
 spec/bundler/install/gemfile/path_spec.rb | 33 +++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 6760edba42c..012229f430c 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -39,7 +39,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L39
     end
 
     def satisfies?(dependency)
-      @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
+      effective_requirement = dependency.requirement == Gem::Requirement.default ? Gem::Requirement.default_prerelease : dependency.requirement
+
+      @name == dependency.name && effective_requirement.satisfied_by?(Gem::Version.new(@version))
     end
 
     def to_lock
diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb
index 4143b04c2aa..db5db31d42d 100644
--- a/spec/bundler/install/gemfile/path_spec.rb
+++ b/spec/bundler/install/gemfile/path_spec.rb
@@ -183,6 +183,39 @@ RSpec.describe "bundle install with explicit source paths" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/path_spec.rb#L183
     expect(the_bundle).to include_gems "foo 1.0"
   end
 
+  it "works when using prereleases of 0.0.0" do
+    build_lib "foo", "0.0.0.dev", :path => lib_path("foo")
+
+    gemfile <<~G
+      source "#{file_uri_for(gem_repo1)}"
+      gem "foo", :path => "#{lib_path("foo")}"
+    G
+
+    lockfile <<~L
+      PATH
+        remote: #{lib_path("foo")}
+        specs:
+          foo (0.0.0.dev)
+
+      GEM
+        remote: #{file_uri_for(gem_repo1)}/
+        specs:
+
+      PLATFORMS
+        #{lockfile_platforms}
+
+      DEPENDENCIES
+        foo!
+
+      BUNDLED WITH
+        #{Bundler::VERSION}
+    L
+
+    bundle :install
+
+    expect(the_bundle).to include_gems "foo 0.0.0.dev"
+  end
+
   it "handles downgrades" do
     build_lib "omg", "2.0", :path => lib_path("omg")
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]