From bc0de1e16250ecb4e8278ec64de86fbc049c5e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 23 Jul 2022 13:47:58 +0200 Subject: [PATCH] [rubygems/rubygems] Only need to filter platforms when materialization is not strict https://github.com/rubygems/rubygems/commit/9d878cbda0 --- lib/bundler/lazy_specification.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 3d704a7f1256ec..4a7f528119d1b3 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -89,21 +89,19 @@ def materialize_for_resolution def __materialize__(platform) @specification = begin - search_object = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform? - Dependency.new(name, version) + candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform? + source.specs.search(Dependency.new(name, version)).select do |spec| + MatchPlatform.platforms_match?(spec.platform, platform) + end else - self + source.specs.search(self) end - candidates = source.specs.search(search_object) - same_platform_candidates = candidates.select do |spec| - MatchPlatform.platforms_match?(spec.platform, platform) - end - installable_candidates = same_platform_candidates.select do |spec| + installable_candidates = candidates.select do |spec| spec.is_a?(StubSpecification) || (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) && spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version)) end - search = installable_candidates.last || same_platform_candidates.last + search = installable_candidates.last || candidates.last search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification)) search end