summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-11-17 21:13:40 +0100
committergit <svn-admin@ruby-lang.org>2021-11-19 10:12:09 +0900
commit55f574136cbcf11339531768524558e03bf7eb7a (patch)
tree30bab2e4db770d02656b81301aa024a37ef8e480
parent2730e45f4565ef41a08d2694be2a287c86f9e0ba (diff)
[rubygems/rubygems] Extract a converge_specs method for later reusing it
https://github.com/rubygems/rubygems/commit/e896e63ac3
-rw-r--r--lib/bundler/definition.rb37
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index d0ae4631d7..c009397b08 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -690,9 +690,27 @@ module Bundler
# commonly happen if the Gemfile has changed since the lockfile was last
# generated
def converge_locked_specs
+ resolve = converge_specs(@locked_specs)
+
+ diff = nil
+
+ # Now, we unlock any sources that do not have anymore gems pinned to it
+ sources.all_sources.each do |source|
+ next unless source.respond_to?(:unlock!)
+
+ unless resolve.any? {|s| s.source == source }
+ diff ||= @locked_specs.to_a - resolve.to_a
+ source.unlock! if diff.any? {|s| s.source == source }
+ end
+ end
+
+ resolve
+ end
+
+ def converge_specs(specs)
deps = []
converged = []
- @locked_specs.each do |s|
+ specs.each do |s|
# Replace the locked dependency's source with the equivalent source from the Gemfile
dep = @dependencies.find {|d| s.satisfies?(d) }
@@ -717,7 +735,7 @@ module Bundler
rescue PathError, GitError
# if we won't need the source (according to the lockfile),
# don't error if the path/git source isn't available
- next if @locked_specs.
+ next if specs.
for(requested_dependencies, false, true).
none? {|locked_spec| locked_spec.source == s.source }
@@ -741,20 +759,7 @@ module Bundler
end
resolve = SpecSet.new(converged)
- resolve = SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
- diff = nil
-
- # Now, we unlock any sources that do not have anymore gems pinned to it
- sources.all_sources.each do |source|
- next unless source.respond_to?(:unlock!)
-
- unless resolve.any? {|s| s.source == source }
- diff ||= @locked_specs.to_a - resolve.to_a
- source.unlock! if diff.any? {|s| s.source == source }
- end
- end
-
- resolve
+ SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
end
def metadata_dependencies