diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-09-10 13:15:19 -0700 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-09-13 15:38:18 -0500 |
commit | 7326958a66c21a19586cbaf9027a08cf2ff20971 (patch) | |
tree | 527e4aed6e33a971fb4952e7e4d1401284965655 /lib/bundler/definition.rb | |
parent | 018ca4b31f2effb1b14bffb625f5430af959573b (diff) | |
download | bundler-7326958a66c21a19586cbaf9027a08cf2ff20971.tar.gz |
Avoid request-bloat in double checking logic
This avoids attempting to double-check in each source for gems that are _in the locally installed set of gems_, which could add hundreds or thousands of extra requests
Diffstat (limited to 'lib/bundler/definition.rb')
-rw-r--r-- | lib/bundler/definition.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index ecb41f83c2..02ad967c2a 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -265,9 +265,8 @@ module Bundler dependency_names = @dependencies.map(&:name) sources.all_sources.each do |source| - source.dependency_names = dependency_names.dup + source.dependency_names = dependency_names - pinned_spec_names(source) idx.add_source source.specs - dependency_names -= pinned_spec_names(source.specs) dependency_names.concat(source.unmet_deps).uniq! end @@ -281,21 +280,25 @@ module Bundler # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for # each spec we found, we add all possible versions from all sources to the index. def double_check_for_index(idx, dependency_names) + pinned_names = pinned_spec_names loop do idxcount = idx.size + + names = :names # do this so we only have to traverse to get dependency_names from the index once + unmet_dependency_names = lambda do + return names unless names == :names + new_names = sources.all_sources.map(&:dependency_names_to_double_check) + return names = nil if new_names.compact! + names = new_names.flatten(1).concat(dependency_names) + names.uniq! + names -= pinned_names + names + end + sources.all_sources.each do |source| - names = :names # do this so we only have to traverse to get dependency_names from the index once - unmet_dependency_names = proc do - break names unless names == :names - names = if idx.size > Source::Rubygems::API_REQUEST_LIMIT - new_names = idx.dependency_names_if_available - new_names && dependency_names.+(new_names).uniq - else - dependency_names.+(idx.dependency_names).uniq - end - end source.double_check_for(unmet_dependency_names, :override_dupes) end + break if idxcount == idx.size end end @@ -916,18 +919,15 @@ module Bundler source_requirements end - def pinned_spec_names(specs) - names = [] - specs.each do |s| - # TODO: when two sources without blocks is an error, we can change - # this check to !s.source.is_a?(Source::LocalRubygems). For now, - # we need to ask every RubyGems for every gem name. - if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path) - names << s.name - end + def pinned_spec_names(skip = nil) + pinned_names = [] + default = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources? && sources.default_source + @dependencies.each do |dep| + dep_source = dep.source || default + next if dep_source == skip + pinned_names << dep.name end - names.uniq! - names + pinned_names end def requested_groups |