diff options
author | Andre Arko <andre@arko.net> | 2013-02-13 12:35:02 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-02-13 19:43:51 -0800 |
commit | cec9e61f954076c9d83e9272892ec965b78f713f (patch) | |
tree | b3064134dcb39780a7c2da46ac1573a794c8f02f | |
parent | 4ff5d8483b2c6082ac3d0777fb120c2e979e3d38 (diff) | |
download | bundler-cec9e61f954076c9d83e9272892ec965b78f713f.tar.gz |
less rescue/try something else craziness
-rw-r--r-- | lib/bundler/fetcher.rb | 53 | ||||
-rw-r--r-- | spec/install/gems/dependency_api_spec.rb | 2 | ||||
-rw-r--r-- | spec/realworld/dependency_api_spec.rb | 2 |
3 files changed, 26 insertions, 31 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index e4a1e81c70..deb1cbdbe1 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -77,38 +77,19 @@ module Bundler def specs(gem_names, source) index = Index.new - specs = nil + if gem_names && use_api + Bundler.ui.info "Fetching gem metadata from #{@public_uri}", Bundler.ui.debug? + specs = fetch_remote_specs(gem_names) + # new line now that the dots are over + Bundler.ui.info "" if specs && !Bundler.ui.debug? + end + + if specs.nil? + # API errors mean we should treat this as a non-API source + @use_api = false - if !gem_names || !use_api Bundler.ui.info "Fetching source index from #{@public_uri}" specs = fetch_all_remote_specs - else - Bundler.ui.info "Fetching gem metadata from #{@public_uri}", Bundler.ui.debug? - begin - specs = fetch_remote_specs(gem_names) - # fall back to the legacy index in the following cases - # 1. Gemcutter Endpoint doesn't return a 200 - # 2,3. Marshal blob doesn't load properly - # 4. One of the YAML gemspecs has the Syck::DefaultKey problem - rescue HTTPError, ArgumentError, TypeError, GemspecError => e - # API errors mean we should treat this as a non-API source - @use_api = false - - # new line now that the dots are over - Bundler.ui.info "" unless Bundler.ui.debug? - - if FallbackError === e - Bundler.ui.debug "API refused request: #{e.message}" - else - Bundler.ui.debug "Error during API request. #{e.class}: #{e.message}" - end - - Bundler.ui.info "Fetching full source index from #{@public_uri}" - specs = fetch_all_remote_specs - else - # new line now that the dots are over - Bundler.ui.info "" unless Bundler.ui.debug? - end end specs[@remote_uri].each do |name, version, platform, dependencies| @@ -146,6 +127,20 @@ module Bundler returned_gems = spec_list.map {|spec| spec.first }.uniq fetch_remote_specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list) + # fall back to the legacy index in the following cases + # 1. Gemcutter Endpoint doesn't return a 200 + # 2,3. Marshal blob doesn't load properly + # 4. One of the YAML gemspecs has the Syck::DefaultKey problem + rescue HTTPError, ArgumentError, TypeError, GemspecError => e + @use_api = false + + # new line now that the dots are over + Bundler.ui.info "" unless Bundler.ui.debug? + + Bundler.ui.debug "Error during API request. #{e.class}: #{e.message}" + Bundler.ui.debug e.backtrace.join(" ") + + return nil end def use_api diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index 62b563b456..4681b32cc3 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -144,7 +144,7 @@ describe "gemcutter's dependency API" do G bundle :install, :artifice => "endpoint_marshal_fail" - expect(out).to include("Fetching full source index from #{source_uri}") + expect(out).to include("Fetching source index from #{source_uri}") should_be_installed "rack 1.0.0" end diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb index b9c6b66e29..fafa4dae1d 100644 --- a/spec/realworld/dependency_api_spec.rb +++ b/spec/realworld/dependency_api_spec.rb @@ -53,7 +53,7 @@ describe "gemcutter's dependency API", :realworld => true do G bundle :install - expect(out).to include("\nFetching full source index from #{@server_uri}") + expect(out).to include("\nFetching source index from #{@server_uri}") should_be_installed "rack 1.0.0" end end |