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

ruby-changes:72780

From: David <ko1@a...>
Date: Tue, 2 Aug 2022 16:10:43 +0900 (JST)
Subject: [ruby-changes:72780] ed9bbfd759 (master): [rubygems/rubygems] Fix incorrect force_ruby_platform propagation

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

From ed9bbfd7594f655702461067e3dc8106eec52385 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sat, 23 Jul 2022 11:58:53 +0200
Subject: [rubygems/rubygems] Fix incorrect force_ruby_platform propagation

It was just working by chance.

(cherry picked from commit https://github.com/rubygems/rubygems/commit/16b2d6bfe893)

https://github.com/rubygems/rubygems/commit/8f922d980f
---
 lib/bundler/rubygems_ext.rb |  4 ++++
 lib/bundler/spec_set.rb     | 19 ++++++++++---------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index e8e03fcf8f..938c58e64d 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -155,6 +155,10 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L155
 
     alias_method :eql?, :==
 
+    def force_ruby_platform
+      false
+    end
+
     def encode_with(coder)
       to_yaml_properties.each do |ivar|
         coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index de2ad97330..6a3813eef8 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -13,14 +13,16 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/spec_set.rb#L13
 
     def for(dependencies, check = false, platforms = [nil])
       handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h
-      deps = dependencies.product(platforms).map {|dep, platform| [dep.name, platform && dep.force_ruby_platform ? Gem::Platform::RUBY : platform] }
+      deps = dependencies.product(platforms)
       specs = []
 
       loop do
         break unless dep = deps.shift
-        next if handled.key?(dep)
 
-        handled[dep] = true
+        key = [dep[0].name, dep[1]]
+        next if handled.key?(key)
+
+        handled[key] = true
 
         specs_for_dep = specs_for_dependency(*dep)
         if specs_for_dep.any?
@@ -28,10 +30,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/spec_set.rb#L30
 
           specs_for_dep.first.dependencies.each do |d|
             next if d.type == :development
-            deps << [d.name, dep[1]]
+            deps << [d, dep[1]]
           end
         elsif check
-          specs << IncompleteSpecification.new(*dep)
+          specs << IncompleteSpecification.new(*key)
         end
       end
 
@@ -175,13 +177,12 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/spec_set.rb#L177
       @specs.sort_by(&:name).each {|s| yield s }
     end
 
-    def specs_for_dependency(name, platform)
-      specs_for_name = lookup[name]
+    def specs_for_dependency(dep, platform)
+      specs_for_name = lookup[dep.name]
       if platform.nil?
         GemHelpers.select_best_platform_match(specs_for_name.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
       else
-        specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, platform)
-        specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name
+        GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : platform)
       end
     end
 
-- 
cgit v1.2.1


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

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