summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-15 16:53:02 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-23 19:40:12 -0500
commit1867eafe120a97f31c5a8a4976dadf4089b13e1f (patch)
tree5df5a132ebe5c691f85857859f9d7a15e795d296
parent358736a1716f2b87879c11858b2672af538ed82d (diff)
downloadbundler-1867eafe120a97f31c5a8a4976dadf4089b13e1f.tar.gz
Avoid fetching the full index to get all dependency names
-rw-r--r--lib/bundler/source/rubygems.rb4
-rw-r--r--spec/install/gems/compact_index_spec.rb24
-rw-r--r--spec/support/artifice/compact_index_extra_api_missing.rb16
3 files changed, 42 insertions, 2 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 8644c05d64..465aec6136 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -249,9 +249,9 @@ module Bundler
return unless api_fetchers.any?
unmet_dependency_names = unmet_dependency_names.call
- Bundler.ui.debug "#{self}: 2x check for #{unmet_dependency_names}"
+ return if !unmet_dependency_names.nil? && unmet_dependency_names.empty?
- return if unmet_dependency_names && unmet_dependency_names.empty?
+ Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
fetch_names(api_fetchers, unmet_dependency_names, index, override_dupes)
end
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index 9fc5b1f90a..ad1abe2e89 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -363,6 +363,30 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "back_deps 1.0"
end
+ it "does not fetch every spec if the index of gems is large when doing back deps & everything is the compact index" do
+ build_repo4 do
+ build_gem "back_deps" do |s|
+ s.add_dependency "foo"
+ end
+ build_gem "missing"
+ # need to hit the limit
+ 1.upto(Bundler::Source::Rubygems::API_REQUEST_LIMIT) do |i|
+ build_gem "gem#{i}"
+ end
+
+ FileUtils.rm_rf Dir[gem_repo4("gems/foo-*.gem")]
+ end
+
+ install_gemfile! <<-G, :artifice => "compact_index_extra_api_missing"
+ source "#{source_uri}"
+ source "#{source_uri}/extra" do
+ gem "back_deps"
+ end
+ G
+
+ expect(the_bundle).to include_gem "back_deps 1.0"
+ end
+
it "uses the endpoint if all sources support it" do
gemfile <<-G
source "#{source_uri}"
diff --git a/spec/support/artifice/compact_index_extra_api_missing.rb b/spec/support/artifice/compact_index_extra_api_missing.rb
new file mode 100644
index 0000000000..d11793fc2b
--- /dev/null
+++ b/spec/support/artifice/compact_index_extra_api_missing.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+require File.expand_path("../compact_index_extra_api", __FILE__)
+
+Artifice.deactivate
+
+class CompactIndexExtraAPIMissing < CompactIndexExtraApi
+ get "/extra/fetch/actual/gem/:id" do
+ if params[:id] == "missing-1.0.gemspec.rz"
+ halt 404
+ else
+ File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
+ end
+ end
+end
+
+Artifice.activate_with(CompactIndexExtraAPIMissing)