summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-07-23 08:44:47 +0200
committergit <svn-admin@ruby-lang.org>2022-08-02 16:10:18 +0900
commitf4f681463f71c2fc63e1a07f36f2665f2b9db002 (patch)
tree6d9c7f6b576fdfcd480156bdbd2ce6b20141307f /lib
parent9189c2d5efa94131050df4994c801fb187d7b43d (diff)
[rubygems/rubygems] Don't discard candidates matching ruby metadata
Do dependency filtering and materialization in one step. Before, dependency filtering would not consider ruby metadata so it would discard variants that end up not being materializable in the end. https://github.com/rubygems/rubygems/commit/0c0d40d417 Co-authored-by: Ian Ker-Seymer <ian.kerseymer@shopify.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/gem_helpers.rb8
-rw-r--r--lib/bundler/lazy_specification.rb6
-rw-r--r--lib/bundler/spec_set.rb7
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 6bc4fb4991..0d50d8687b 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -44,6 +44,12 @@ module Bundler
def select_best_platform_match(specs, platform)
matching = specs.select {|spec| spec.match_platform(platform) }
+
+ sort_best_platform_match(matching, platform)
+ end
+ module_function :select_best_platform_match
+
+ def sort_best_platform_match(matching, platform)
exact = matching.select {|spec| spec.platform == platform }
return exact if exact.any?
@@ -52,7 +58,7 @@ module Bundler
sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
end
- module_function :select_best_platform_match
+ module_function :sort_best_platform_match
class PlatformMatch
def self.specificity_score(spec_platform, user_platform)
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 805afba51f..a88172d96b 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -88,6 +88,8 @@ module Bundler
source.specs.search(self)
end
+ return self if candidates.empty?
+
__materialize__(candidates)
end
@@ -105,8 +107,8 @@ module Bundler
spec.is_a?(StubSpecification) ||
(spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
- end || candidates.last
- search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
+ end
+ search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
search
end
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 6a3813eef8..e21a3ea6f5 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -66,10 +66,6 @@ module Bundler
def materialize(deps)
materialized = self.for(deps, true).uniq
- materialized.map! do |s|
- next s unless s.is_a?(LazySpecification)
- s.materialize_for_installation || s
- end
SpecSet.new(materialized)
end
@@ -180,7 +176,8 @@ module Bundler
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)
+ matching_specs = specs_for_name.map {|s| s.materialize_for_installation if Gem::Platform.match_spec?(s) }.compact
+ GemHelpers.sort_best_platform_match(matching_specs, Bundler.local_platform)
else
GemHelpers.select_best_platform_match(specs_for_name, dep.force_ruby_platform ? Gem::Platform::RUBY : platform)
end