diff options
author | The Bundler Bot <bot@bundler.io> | 2016-12-19 09:22:01 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2016-12-19 09:22:01 +0000 |
commit | 9eefcbece2378b2c355e58f2a5a208d4ab0e8315 (patch) | |
tree | 5fae98cc83800a9e4f431b2075ec3af7147bd7ab | |
parent | 4f3e0ec66d6f72d00b552959db1dae89b83b4a4e (diff) | |
parent | 5a61b65ad5ec1df1539ecf8bc5d124f2b254ba14 (diff) | |
download | bundler-9eefcbece2378b2c355e58f2a5a208d4ab0e8315.tar.gz |
Auto merge of #5247 - colby-swandale:missing-new-line-on-fetch, r=segiddins
Add a new line for before priring BundlerError errors
This PR is fixing a problem where the warnings and errors on a `bundle install` using an invalid source are not being put on a newline correctly.
```
› bundle install
Fetching source index from https://www.google.com/
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://www.google.com/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://www.google.com/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://www.google.com/Could not fetch specs from https://www.google.com/
```
This is happening because the new lines for the warnings are being printed before the error itself. This behaviour is happening due to another UI problem, see https://github.com/bundler/bundler/commit/2ac26bc88ba30b28aba6e11c9b2d04cdb0276a25.
Maybe a better way of fixing this problem is to add a new line to the exception message itself rather then what i have submitted. Its a bit of a weird one.
Let me know.
-rw-r--r-- | lib/bundler/retry.rb | 5 | ||||
-rw-r--r-- | spec/bundler/retry_spec.rb | 4 | ||||
-rw-r--r-- | spec/realworld/mirror_probe_spec.rb | 16 |
3 files changed, 22 insertions, 3 deletions
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index a7a72feed5..092fb866b3 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -43,7 +43,10 @@ module Bundler def fail_attempt(e) @failed = true - raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) } + if last_attempt? || @exceptions.any? {|k| e.is_a?(k) } + Bundler.ui.info "" unless Bundler.ui.debug? + raise e + end return true unless name Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug? diff --git a/spec/bundler/retry_spec.rb b/spec/bundler/retry_spec.rb index 665ba9f2df..7f5779a5ca 100644 --- a/spec/bundler/retry_spec.rb +++ b/spec/bundler/retry_spec.rb @@ -65,10 +65,10 @@ describe Bundler::Retry do end end - context "with debugging on" do + context "with debugging off" do it "print error message with newlines" do allow(Bundler.ui).to receive(:debug?).and_return(false) - expect(Bundler.ui).to receive(:info).with("") + expect(Bundler.ui).to receive(:info).with("").twice expect(Bundler.ui).to receive(:warn).with(failure_message, false) expect do diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb index 0fb93b8ab1..5a4a4a1b0a 100644 --- a/spec/realworld/mirror_probe_spec.rb +++ b/spec/realworld/mirror_probe_spec.rb @@ -79,6 +79,22 @@ describe "fetching dependencies with a not available mirror", :realworld => true expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}") expect(out).to include("Could not fetch specs from #{mirror}") end + + it "prints each error and warning on a new line" do + gemfile <<-G + source "#{original}" + gem 'weakling' + G + + bundle :install + + expect(out).to eq "Fetching source index from #{mirror}/ + +Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}/ +Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}/ +Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}/ +Could not fetch specs from #{mirror}/" + end end context "with a global mirror without a fallback timeout" do |