diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-06 17:23:06 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-08-08 14:23:51 +0200 |
commit | 79c8ed6adf3fbccf09eaad842f80bd077b3aca74 (patch) | |
tree | eb4b75bb79d4d23c8e6819b7e7f8b4986382d23a | |
parent | b29a40820f245a3adefd1bdac1b71065c789f0c9 (diff) | |
download | bundler-79c8ed6adf3fbccf09eaad842f80bd077b3aca74.tar.gz |
Refactor UI's to avoid silencing some messagesremove_major_deprecation_ui
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | lib/bundler/deployment.rb | 5 | ||||
-rw-r--r-- | lib/bundler/setup.rb | 24 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 4 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 8 | ||||
-rw-r--r-- | spec/other/platform_spec.rb | 3 | ||||
-rw-r--r-- | spec/runtime/executable_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/require_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 15 |
9 files changed, 32 insertions, 32 deletions
diff --git a/.travis.yml b/.travis.yml index 7ed3a6d5cc..0819e64140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ branches: - trying - /.+-dev$/ - /.+-stable$/ + - remove_major_deprecation_ui cache: directories: diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index b432ae6ae1..b21d89899f 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,6 +1,11 @@ # frozen_string_literal: true require_relative "shared_helpers" + +require_relative "../bundler" + +Bundler.ui = Bundler::UI::Shell.new + Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \ "Capistrano, but Capistrano provides its own integration with " \ "Bundler via the capistrano-bundler gem. Use it instead." diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb index d156f494a8..48f3c7c323 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -5,25 +5,19 @@ require_relative "shared_helpers" if Bundler::SharedHelpers.in_bundle? require_relative "../bundler" - if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"] - Bundler.ui = Bundler::UI::Shell.new - begin - Bundler.setup - rescue Bundler::BundlerError => e - Bundler.ui.warn "\e[31m#{e.message}\e[0m" - Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"] - if e.is_a?(Bundler::GemNotFound) - Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m" - end - exit e.status_code - end - else + Bundler.ui = Bundler::UI::Shell.new + begin Bundler.setup + rescue Bundler::BundlerError => e + Bundler.ui.warn "\e[31m#{e.message}\e[0m" + Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"] + if e.is_a?(Bundler::GemNotFound) + Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m" + end + exit e.status_code end # Add bundler to the load path after disabling system gems bundler_lib = File.expand_path("../..", __FILE__) $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib) - - Bundler.ui = nil end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 00ff541598..cf7c206814 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -133,9 +133,7 @@ module Bundler end return unless bundler_major_version >= major_version && prints_major_deprecations? - @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true) - ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui - ui.warn("[DEPRECATED] #{message}") + Bundler.ui.warn("[DEPRECATED] #{message}") end def print_major_deprecations! diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 8ad5a3c125..b0f28a0442 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "bundle exec" do G bundle "exec --gemfile CustomGemfile rackup" - expect(out).to eq("1.0.0") + expect(out).to eq("Resolving dependencies...\n1.0.0") end it "activates the correct gem" do @@ -21,7 +21,7 @@ RSpec.describe "bundle exec" do G bundle "exec rackup" - expect(out).to eq("0.9.1") + expect(out).to eq("Resolving dependencies...\n0.9.1") end it "works when the bins are in ~/.bundle" do @@ -63,7 +63,7 @@ RSpec.describe "bundle exec" do create_file "Gemfile" create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility bundle "exec ruby a.rb" - expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") + expect(out).to eq("Resolving dependencies...\n1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") end it "accepts --verbose" do @@ -703,7 +703,6 @@ RSpec.describe "bundle exec" do gemfile <<-G gem 'rack', '2' G - ENV["BUNDLER_FORCE_TTY"] = "true" end let(:exit_code) { Bundler::GemNotFound.new.status_code } @@ -721,7 +720,6 @@ RSpec.describe "bundle exec" do gemfile <<-G gem 'rack', '2' G - ENV["BUNDLER_FORCE_TTY"] = "true" end let(:exit_code) { Bundler::GemNotFound.new.status_code } diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index b61a3f1b03..6e3a78932b 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -849,7 +849,6 @@ G context "bundle exec" do before do - ENV["BUNDLER_FORCE_TTY"] = "true" system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path end @@ -1038,8 +1037,6 @@ G gem "yard" gem "rack", :group => :test G - - ENV["BUNDLER_FORCE_TTY"] = "true" end it "makes a Gemfile.lock if setup succeeds" do diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index 003be97cd6..0caafc43c1 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -75,7 +75,7 @@ RSpec.describe "Running bin/* commands" do end gembin "rackup" - expect(out).to eq("1.0") + expect(out).to eq("Resolving dependencies...\n1.0") end it "creates a bundle binstub" do diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index 016fc14dfe..dfe1487008 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -265,7 +265,7 @@ RSpec.describe "Bundler.require" do describe "using bundle exec" do it "requires the locked gems" do bundle "exec ruby -e 'Bundler.require'" - expect(out).to eq("two") + expect(out).to eq("Resolving dependencies...\ntwo") bundle "exec ruby -e 'Bundler.require(:bar)'" expect(out).to eq("baz\nqux") diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 866f4862c5..f2e7a9859b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1107,19 +1107,26 @@ end end context "is newer" do - it "does not change the lock or warn" do + it "does not change the lock but warns" do lockfile lock_with(Bundler::VERSION.succ) ruby "require 'bundler/setup'" expect(out).to eq("") - expect(err).to eq("") + suggested_cmd = "gem install bundler:#{Bundler::VERSION.succ}" + suggested_cmd += " --pre" if Gem::Version.new(Bundler::VERSION).prerelease? + expect(err).to eq( + "Warning: the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ}). " \ + "We suggest you to upgrade to the version that created the lockfile by running `#{suggested_cmd}`." + ) lockfile_should_be lock_with(Bundler::VERSION.succ) end end context "is older" do - it "does not change the lock" do + it "does not change the lock or warn" do lockfile lock_with("1.10.1") ruby "require 'bundler/setup'" + expect(out).to eq("") + expect(err).to eq("") lockfile_should_be lock_with("1.10.1") end end @@ -1189,7 +1196,7 @@ end describe "with gemified standard libraries" do it "does not load Psych" do - gemfile "" + install_gemfile "" ruby <<-RUBY require 'bundler/setup' puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined" |