diff options
author | The Bundler Bot <bot@bundler.io> | 2017-07-20 19:03:59 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-07-21 14:44:34 -0500 |
commit | 164fecf1118a7845bae421acc1452b33cf29db8b (patch) | |
tree | d75f2b5df148255ccf1f7cf085c1b2712fc4dc50 | |
parent | 50905839daa6c381b3759375d69194309c5f6544 (diff) | |
download | bundler-164fecf1118a7845bae421acc1452b33cf29db8b.tar.gz |
Auto merge of #5884 - bundler:seg-no-bundler-versio-warning-when-parseable, r=segiddins
[CLI] Dont print an outdated version warning when running a parseable command
### What was the end-user problem that led to this PR?
The problem was the outdated bundler version warning could be printed when running a command whose output should be parseable.
@schneems pointed this out on twitter
### What was your diagnosis of the problem?
My diagnosis was parsable commands needed to have such extraneous output suppressed.
### What is your fix for the problem, implemented in this PR?
My fix was to use the blacklist from printing the running command to bail out on the outdated bundler version warning as well.
### Why did you choose this fix out of the possible options?
I chose this fix because it means we can have a single list of parseable command.
(cherry picked from commit 4da6724d61257d658c048b83e5b60be91d6658a6)
# Conflicts:
# lib/bundler/cli.rb
# spec/bundler/cli_spec.rb
-rw-r--r-- | lib/bundler/cli.rb | 19 | ||||
-rw-r--r-- | spec/bundler/cli_spec.rb | 15 |
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 5b5d4e4f78..3893b96f49 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -5,6 +5,9 @@ require "bundler/vendored_thor" module Bundler class CLI < Thor AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean).freeze + PARSEABLE_COMMANDS = %w( + check config help exec platform show version + ).freeze def self.start(*) super @@ -12,12 +15,14 @@ module Bundler Bundler.ui = UI::Shell.new raise e ensure - warn_on_outdated_bundler Bundler::SharedHelpers.print_major_deprecations! end def self.dispatch(*) - super {|i| i.send(:print_command) } + super do |i| + i.send(:print_command) + i.send(:warn_on_outdated_bundler) + end end def initialize(*args) @@ -616,7 +621,7 @@ module Bundler _, _, config = @_initializer current_command = config[:current_command] command_name = current_command.name - return if %w(exec version check platform show help).include?(command_name) + return if PARSEABLE_COMMANDS.include?(command_name) command = ["bundle", command_name] + args options_to_print = options.dup options_to_print.delete_if do |k, v| @@ -628,9 +633,14 @@ module Bundler Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}" end - def self.warn_on_outdated_bundler + def warn_on_outdated_bundler return if Bundler.settings[:disable_version_check] + _, _, config = @_initializer + current_command = config[:current_command] + command_name = current_command.name + return if PARSEABLE_COMMANDS.include?(command_name) + latest = Fetcher::CompactIndex. new(nil, Source::Rubygems::Remote.new(URI("https://rubygems.org")), nil). send(:compact_index_client). @@ -647,6 +657,5 @@ module Bundler rescue nil end - private_class_method :warn_on_outdated_bundler end end diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index 4963698c8e..536face347 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -57,8 +57,9 @@ RSpec.describe "bundle executable" do context "with --verbose" do it "prints the running command" do - bundle! "config", :verbose => true - expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}") + gemfile "" + bundle! "info bundler", :verbose => true + expect(out).to start_with("Running `bundle info bundler --no-color --verbose` with bundler #{Bundler::VERSION}") end it "doesn't print defaults" do @@ -116,6 +117,16 @@ Could not find command "fail". include_examples "no warning" end + context "running a parseable command" do + it "prints no warning" do + bundle! "config --parseable foo" + expect(last_command.stdboth).to eq "" + + bundle "platform --ruby" + expect(last_command.stdboth).to eq "Could not locate Gemfile" + end + end + context "and is a pre-release" do let(:latest_version) { "2.0.0.pre.4" } it "prints the version warning" do |