summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-03-17 13:04:23 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-03-24 13:25:07 +0900
commit5bff692346bda9f282acbe4236dc7ddabc0b90be (patch)
treeefceead1b67d1809a8aa28699ae6cd2eab2ef61b
parent28943c2820b8f620b98a951c0ae1f821b0880a8e (diff)
[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
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12968
-rw-r--r--lib/bundler/definition.rb15
-rw-r--r--lib/bundler/lazy_specification.rb8
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?