From 5bff692346bda9f282acbe4236dc7ddabc0b90be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 17 Mar 2025 13:04:23 +0100 Subject: [rubygems/rubygems] Refactor replacing locked specification path sources Instead of doing an explicit pass, let sources be replaced while checking if specifications are up to date. https://github.com/rubygems/rubygems/commit/676271e804 --- lib/bundler/definition.rb | 15 +-------------- lib/bundler/lazy_specification.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1d024032bb..2e1192d46e 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -147,7 +147,6 @@ module Bundler @current_platform_missing = add_current_platform unless Bundler.frozen_bundle? - converge_path_sources_to_gemspec_sources @path_changes = converge_paths @source_changes = converge_sources @@ -842,7 +841,7 @@ module Bundler def specs_for_source_changed?(source) locked_index = Index.new - locked_index.use(@locked_specs.select {|s| source.can_lock?(s) }) + locked_index.use(@locked_specs.select {|s| s.replace_source_with!(source) }) !locked_index.subset?(source.specs) rescue PathError, GitError => e @@ -904,18 +903,6 @@ module Bundler end end - def converge_path_source_to_gemspec_source(source) - return source unless source.instance_of?(Source::Path) - gemspec_source = sources.path_sources.find {|s| s == source } - gemspec_source || source - end - - def converge_path_sources_to_gemspec_sources - @locked_specs.each do |spec| - spec.source &&= converge_path_source_to_gemspec_source(spec.source) - end - end - def converge_sources # Replace the sources from the Gemfile with the sources from the Gemfile.lock, # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 77c0563ac6..e617d32410 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -175,6 +175,14 @@ module Bundler @force_ruby_platform = true end + def replace_source_with!(gemfile_source) + return unless gemfile_source.can_lock?(self) + + @source = gemfile_source + + true + end + private def use_exact_resolved_specifications? -- cgit v1.2.3