diff options
author | Homu <homu@barosl.com> | 2016-07-26 22:50:21 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-07-26 22:50:21 +0900 |
commit | 6904ac6872be56290b12088a6595480de2ae9c53 (patch) | |
tree | de6dff8b7eb6cd92487770a5d1de168540f1a722 /lib/bundler | |
parent | 2b649723dc7730b79df7dee3837afcff949f3d3a (diff) | |
parent | 8b59481c9fb11d8273ff7606593682dfeabd7dd9 (diff) | |
download | bundler-6904ac6872be56290b12088a6595480de2ae9c53.tar.gz |
Auto merge of #4811 - NickLaMuro:dots_for_compact_index_logger, r=segiddins
Fix random string printing inconsistencies and formatting
Add dot output for CompactIndex fetcher
---------------------------------------
The `Bundler::Fetcher::CompactIndex`'s logging was missing the "dot logging" when not in debug mode, which is an assumed behavior based on the code in `lib/bundler/source/rubygems.rb`:
```ruby
api_fetchers.each do |f|
Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
idx.use f.specs_with_retry(dependency_names, self)
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
end
```
While this isn't critical for `bundler` function properly by any stretch of the imagination, it provides a small bit of user feedback that requests are still continuing to be processed and `bundler` hasn't stalled. It also maintains logging consistency between the different fetcher models.
Add newlines for `Bundler::Retry`
---------------------------------
This is very pedantic, but it makes it so that retry warning messages that used to look like this:
```
Fetching gem metadata from https://rubygems.org/....Retrying fetcher due to error (2/4): Error::OMGWatHappened LOL, no idea
.....
```
Now will look like this:
```
Fetching gem metadata from https://rubygems.org/....
Retrying fetcher due to error (2/4): Error::OMGWatHappened LOL, no idea.....
```
I think this reads a bit better and puts context to the "dots" so they now match up with the original attempt and the retries
Remove unneeded if statement
----------------------------
Ran across this while failing at writing tests for the above (for longer than I want to admit in public), but basically the `if` statement to determine whether or not to print "name" in the `Bundler.ui.warn` was not needed, as it never could be reached because of a short circuiting return statement prior to the print
```ruby
return true unless name
```
Have no idea how to test it anymore than we already are, so instead of embarrassing myself further, I moved on.
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/fetcher/base.rb | 10 | ||||
-rw-r--r-- | lib/bundler/fetcher/compact_index.rb | 2 | ||||
-rw-r--r-- | lib/bundler/fetcher/dependency.rb | 13 | ||||
-rw-r--r-- | lib/bundler/retry.rb | 3 |
4 files changed, 14 insertions, 14 deletions
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb index 6714ea2cd7..271729a534 100644 --- a/lib/bundler/fetcher/base.rb +++ b/lib/bundler/fetcher/base.rb @@ -36,6 +36,16 @@ module Bundler def api_fetcher? false end + + private + + def log_specs(debug_msg) + if Bundler.ui.debug? + Bundler.ui.debug debug_msg + else + Bundler.ui.info ".", false + end + end end end end diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index c0e1b3b4cf..e6f936c2fe 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -36,7 +36,7 @@ module Bundler remaining_gems = gem_names.dup until remaining_gems.empty? - Bundler.ui.debug "Looking up gems #{remaining_gems.inspect}" + log_specs "Looking up gems #{remaining_gems.inspect}" deps = compact_index_client.dependencies(remaining_gems) next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb index a145837a88..1cd5f9a213 100644 --- a/lib/bundler/fetcher/dependency.rb +++ b/lib/bundler/fetcher/dependency.rb @@ -23,7 +23,7 @@ module Bundler def specs(gem_names, full_dependency_list = [], last_spec_list = []) query_list = gem_names.uniq - full_dependency_list - log_specs(query_list) + log_specs "Query List: #{query_list.inspect}" return last_spec_list if query_list.empty? @@ -76,17 +76,6 @@ module Bundler uri.query = "gems=#{CGI.escape(gem_names.join(","))}" if gem_names.any? uri end - - private - - def log_specs(query_list) - # only display the message on the first run - if Bundler.ui.debug? - Bundler.ui.debug "Query List: #{query_list.inspect}" - else - Bundler.ui.info ".", false - end - end end end end diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index bf4d6ab7f7..a7a72feed5 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -45,7 +45,8 @@ module Bundler @failed = true raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) } return true unless name - Bundler.ui.warn "Retrying#{" #{name}" if name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}" + 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? end def keep_trying? |