Fix logging the fallback to the full index on GemspecError's

The debug message suggests retrying using `--full-index`, but the retry
is happening automatically. Just log that we are falling back to the
full index, like we do with other errors.
This commit is contained in:
David Rodríguez 2023-03-16 15:44:51 +01:00 коммит произвёл Hiroshi SHIBATA
Родитель 069640d355
Коммит 164dc58008
2 изменённых файлов: 7 добавлений и 15 удалений

Просмотреть файл

@ -34,14 +34,10 @@ module Bundler
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
rescue MarshalError
rescue MarshalError, HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
rescue HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
nil
end
def dependency_specs(gem_names)

Просмотреть файл

@ -155,9 +155,9 @@ RSpec.describe Bundler::Fetcher::Dependency do
end
end
shared_examples_for "the error suggests retrying with the full index" do
it "should log the inability to fetch from API at debug level" do
expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`")
shared_examples_for "the error is logged" do
it "should log the inability to fetch from API at debug level, and mention retrying" do
expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
subject.specs(gem_names, full_dependency_list, last_spec_list)
end
end
@ -166,25 +166,21 @@ RSpec.describe Bundler::Fetcher::Dependency do
before { allow(subject).to receive(:dependency_specs) { raise Bundler::HTTPError.new } }
it_behaves_like "the error is properly handled"
it_behaves_like "the error suggests retrying with the full index"
it_behaves_like "the error is logged"
end
context "when a GemspecError occurs" do
before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
it_behaves_like "the error is properly handled"
it_behaves_like "the error suggests retrying with the full index"
it_behaves_like "the error is logged"
end
context "when a MarshalError occurs" do
before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
it_behaves_like "the error is properly handled"
it "should log the inability to fetch from API and mention retrying" do
expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
subject.specs(gem_names, full_dependency_list, last_spec_list)
end
it_behaves_like "the error is logged"
end
end