From 10de74b75b8e74b2758f806d18522b096dc60c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Nov 2024 11:50:07 +0100 Subject: [PATCH] [rubygems/rubygems] Avoid needing a second pass to ignore unlocked gems When converging locked specifications to select the ones that should be preserved while resolving, we can avoid having to do a second pass to ignore the ones that have been explicitly unlocked. https://github.com/rubygems/rubygems/commit/411742703e --- lib/bundler/definition.rb | 6 +++--- lib/bundler/spec_set.rb | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 37e80956eb..76397c4045 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -619,8 +619,8 @@ module Bundler end end - def filter_specs(specs, deps) - SpecSet.new(specs).for(deps, platforms) + def filter_specs(specs, deps, skips: []) + SpecSet.new(specs).for(deps, platforms, skips: skips) end def materialize(dependencies) @@ -1022,7 +1022,7 @@ module Bundler converged << s end - filter_specs(converged, deps).reject {|s| @gems_to_unlock.include?(s.name) } + filter_specs(converged, deps, skips: @gems_to_unlock) end def metadata_dependencies diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 05921cb655..abb194b808 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -11,7 +11,7 @@ module Bundler @specs = specs end - def for(dependencies, platforms_or_legacy_check = [nil], legacy_platforms = [nil]) + def for(dependencies, platforms_or_legacy_check = [nil], legacy_platforms = [nil], skips: []) platforms = if [true, false].include?(platforms_or_legacy_check) Bundler::SharedHelpers.major_deprecation 2, "SpecSet#for received a `check` parameter, but that's no longer used and deprecated. " \ @@ -23,7 +23,7 @@ module Bundler platforms_or_legacy_check end - materialize_dependencies(dependencies, platforms) + materialize_dependencies(dependencies, platforms, skips: skips) @materializations.flat_map(&:specs).uniq end @@ -212,7 +212,7 @@ module Bundler private - def materialize_dependencies(dependencies, platforms = [nil]) + def materialize_dependencies(dependencies, platforms = [nil], skips: []) handled = ["bundler"].product(platforms).map {|k| [k, true] }.to_h deps = dependencies.product(platforms) @materializations = [] @@ -233,7 +233,7 @@ module Bundler deps.concat(materialization.dependencies) if materialization.complete? - @materializations << materialization + @materializations << materialization unless skips.include?(name) end @materializations