summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-02-03 17:44:02 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-02-13 09:37:50 +0900
commitbb764e42baa8c99a15d7440cf2e4e1c980219b5d (patch)
treeed35e6435fa37137b0894e685801f9c5714dfaa3
parent7ac29372ca84ff8b0df8c6fc137fe99b4f1fc4e3 (diff)
[rubygems/rubygems] Extract some common materialization logic to a method
https://github.com/rubygems/rubygems/commit/32982fcd33
-rw-r--r--lib/bundler/lazy_specification.rb33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index ba48f2e89e..1cf049c3d8 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -124,10 +124,9 @@ module Bundler
def materialize_strictly
source.local!
- matching_specs = source.specs.search(self)
- return self if matching_specs.empty?
-
- choose_compatible(matching_specs)
+ materialize(self) do |matching_specs|
+ choose_compatible(matching_specs)
+ end
end
def materialized_for_installation
@@ -142,21 +141,20 @@ module Bundler
if use_exact_resolved_specifications?
materialize_strictly
else
- matching_specs = source.specs.search([name, version])
- return self if matching_specs.empty?
+ materialize([name, version]) do |matching_specs|
+ target_platform = source.is_a?(Source::Path) ? platform : local_platform
- target_platform = source.is_a?(Source::Path) ? platform : local_platform
+ installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
- installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
+ specification = choose_compatible(installable_candidates, fallback_to_non_installable: false)
+ return specification unless specification.nil?
- specification = choose_compatible(installable_candidates, fallback_to_non_installable: false)
- return specification unless specification.nil?
+ if target_platform != platform
+ installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
+ end
- if target_platform != platform
- installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
+ choose_compatible(installable_candidates)
end
-
- choose_compatible(installable_candidates)
end
end
@@ -189,6 +187,13 @@ module Bundler
(most_specific_locked_platform != generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
end
+ def materialize(query)
+ matching_specs = source.specs.search(query)
+ return self if matching_specs.empty?
+
+ yield matching_specs
+ end
+
# If in frozen mode, we fallback to a non-installable candidate because by
# doing this we avoid re-resolving and potentially end up changing the
# lock file, which is not allowed. In that case, we will give a proper error