summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-10-30 15:42:08 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-10-31 12:03:49 +0100
commitb401c850c323f6cb2bb17efb6e6def2980356818 (patch)
tree64599037178d6bd627f27463d33971cebd8b3275
parent5ba1360de631e2fabf2bfa998b104c4355c58b13 (diff)
downloadbundler-b401c850c323f6cb2bb17efb6e6def2980356818.tar.gz
Don't silence the UI by default
-rw-r--r--lib/bundler.rb4
-rw-r--r--lib/bundler/cli.rb3
-rw-r--r--lib/bundler/gem_helper.rb1
-rw-r--r--lib/bundler/inline.rb2
-rw-r--r--lib/bundler/rubygems_integration.rb1
-rw-r--r--lib/bundler/setup.rb7
-rw-r--r--lib/bundler/shared_helpers.rb20
-rw-r--r--spec/bundler/source_spec.rb31
-rw-r--r--spec/other/major_deprecation_spec.rb1
-rw-r--r--spec/realworld/edgecases_spec.rb10
-rw-r--r--spec/runtime/platform_spec.rb2
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/helpers.rb4
13 files changed, 40 insertions, 48 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 4321a7ed3d..2ada6fe789 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -64,11 +64,11 @@ module Bundler
end
def ui
- (defined?(@ui) && @ui) || (self.ui = UI::Silent.new)
+ (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)
end
def ui=(ui)
- Bundler.rubygems.ui = ui ? UI::RGProxy.new(ui) : nil
+ Bundler.rubygems.ui = UI::RGProxy.new(ui)
@ui = ui
end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 39f42c9a70..6a31779dc4 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -15,9 +15,6 @@ module Bundler
def self.start(*)
super
- rescue Exception => e # rubocop:disable Lint/RescueException
- Bundler.ui = UI::Shell.new
- raise e
ensure
Bundler::SharedHelpers.print_major_deprecations!
end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index d00c1894a8..81872b9429 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -26,7 +26,6 @@ module Bundler
attr_reader :spec_path, :base, :gemspec
def initialize(base = nil, name = nil)
- Bundler.ui = UI::Shell.new
@base = (base ||= SharedHelpers.pwd)
gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "{,*}.gemspec")]
raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index dbf737c7ee..5491555d67 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -56,7 +56,7 @@ def gemfile(install = false, options = {}, &gemfile)
definition.missing_specs?
end
- Bundler.ui = ui if install
+ Bundler.ui = install ? ui : Bundler::UI::Silent.new
if install || missing_specs.call
Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do
installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 7549c592f1..c4950d14e8 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -635,7 +635,6 @@ module Bundler
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
require_relative "gemdeps"
runtime = Bundler.setup
- Bundler.ui = nil
activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
[Gemdeps.new(runtime), activated_spec_names]
end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
index d156f494a8..b9a2f8f1da 100644
--- a/lib/bundler/setup.rb
+++ b/lib/bundler/setup.rb
@@ -6,9 +6,8 @@ if Bundler::SharedHelpers.in_bundle?
require_relative "../bundler"
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
- Bundler.ui = Bundler::UI::Shell.new
begin
- Bundler.setup
+ Bundler.ui.silence { 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"]
@@ -18,12 +17,10 @@ if Bundler::SharedHelpers.in_bundle?
exit e.status_code
end
else
- Bundler.setup
+ Bundler.ui.silence { Bundler.setup }
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 dec03ed160..6e83bc5ff4 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -137,10 +137,7 @@ module Bundler
end
return unless bundler_major_version >= major_version && prints_major_deprecations?
- @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
- with_major_deprecation_ui do |ui|
- ui.warn("[DEPRECATED] #{message}")
- end
+ Bundler.ui.warn("[DEPRECATED] #{message}")
end
def print_major_deprecations!
@@ -217,21 +214,6 @@ module Bundler
private
- def with_major_deprecation_ui(&block)
- ui = Bundler.ui
-
- if ui.is_a?(@major_deprecation_ui.class)
- yield ui
- else
- begin
- Bundler.ui = @major_deprecation_ui
- yield Bundler.ui
- ensure
- Bundler.ui = ui
- end
- end
- end
-
def validate_bundle_path
path_separator = Bundler.rubygems.path_separator
return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
diff --git a/spec/bundler/source_spec.rb b/spec/bundler/source_spec.rb
index 5b11503d23..0c35c27fdf 100644
--- a/spec/bundler/source_spec.rb
+++ b/spec/bundler/source_spec.rb
@@ -59,7 +59,6 @@ RSpec.describe Bundler::Source do
context "with color", :no_color_tty do
before do
allow($stdout).to receive(:tty?).and_return(true)
- Bundler.ui = Bundler::UI::Shell.new
end
it "should return a string with the spec name and version and locked spec version" do
@@ -68,7 +67,11 @@ RSpec.describe Bundler::Source do
end
context "without color" do
- before { Bundler.ui = Bundler::UI::Shell.new("no-color" => true) }
+ around do |example|
+ with_ui(Bundler::UI::Shell.new("no-color" => true)) do
+ example.run
+ end
+ end
it "should return a string with the spec name and version and locked spec version" do
expect(subject.version_message(spec)).to eq("nokogiri >= 1.6 (was < 1.5)")
@@ -83,7 +86,6 @@ RSpec.describe Bundler::Source do
context "with color", :no_color_tty do
before do
allow($stdout).to receive(:tty?).and_return(true)
- Bundler.ui = Bundler::UI::Shell.new
end
it "should return a string with the locked spec version in yellow" do
@@ -92,7 +94,11 @@ RSpec.describe Bundler::Source do
end
context "without color" do
- before { Bundler.ui = Bundler::UI::Shell.new("no-color" => true) }
+ around do |example|
+ with_ui(Bundler::UI::Shell.new("no-color" => true)) do
+ example.run
+ end
+ end
it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.6.1 (was 1.7.0)")
@@ -107,7 +113,6 @@ RSpec.describe Bundler::Source do
context "with color", :no_color_tty do
before do
allow($stdout).to receive(:tty?).and_return(true)
- Bundler.ui = Bundler::UI::Shell.new
end
it "should return a string with the locked spec version in green" do
@@ -116,7 +121,11 @@ RSpec.describe Bundler::Source do
end
context "without color" do
- before { Bundler.ui = Bundler::UI::Shell.new("no-color" => true) }
+ around do |example|
+ with_ui(Bundler::UI::Shell.new("no-color" => true)) do
+ example.run
+ end
+ end
it "should return a string with the locked spec version in yellow" do
expect(subject.version_message(spec)).to eq("nokogiri 1.7.1 (was 1.7.0)")
@@ -178,4 +187,14 @@ RSpec.describe Bundler::Source do
end
end
end
+
+private
+
+ def with_ui(ui)
+ old_ui = Bundler.ui
+ Bundler.ui = ui
+ yield
+ ensure
+ Bundler.ui = old_ui
+ end
end
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index 52fb532a4a..57b68fdb97 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -360,7 +360,6 @@ RSpec.describe "major deprecations" do
require 'bundler'
require 'bundler/vendored_thor'
- Bundler.ui = Bundler::UI::Shell.new
Bundler.setup
Bundler.setup
RUBY
diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb
index 6468ee7f1e..26dd096b28 100644
--- a/spec/realworld/edgecases_spec.rb
+++ b/spec/realworld/edgecases_spec.rb
@@ -7,10 +7,12 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
require "bundler"
require "bundler/source/rubygems/remote"
require "bundler/fetcher"
- source = Bundler::Source::Rubygems::Remote.new(URI("https://rubygems.org"))
- fetcher = Bundler::Fetcher.new(source)
- index = fetcher.specs([#{name.dump}], nil)
- rubygem = index.search(Gem::Dependency.new(#{name.dump}, #{requirement.dump})).last
+ rubygem = Bundler.ui.silence do
+ source = Bundler::Source::Rubygems::Remote.new(URI("https://rubygems.org"))
+ fetcher = Bundler::Fetcher.new(source)
+ index = fetcher.specs([#{name.dump}], nil)
+ index.search(Gem::Dependency.new(#{name.dump}, #{requirement.dump})).last
+ end
if rubygem.nil?
raise "Could not find #{name} (#{requirement}) on rubygems.org!\n" \
"Found specs:\n\#{index.send(:specs).inspect}"
diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index c504685ea3..f7e93eacf1 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
ruby <<-R
begin
require 'bundler'
- Bundler.setup
+ Bundler.ui.silence { Bundler.setup }
rescue Bundler::GemNotFound => e
puts "WIN"
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 34982c8ca8..98bc21e537 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -107,7 +107,7 @@ RSpec.configure do |config|
in_app_root
@command_executions = []
- example.run
+ Bundler.ui.silence { example.run }
all_output = @command_executions.map(&:to_s_verbose).join("\n\n")
if example.exception && !all_output.empty?
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index ffcde39df7..76a1f77b72 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -19,8 +19,6 @@ module Spec
FileUtils.mkdir_p(home)
FileUtils.mkdir_p(tmpdir)
Bundler.reset!
- Bundler.ui = nil
- Bundler.ui # force it to initialize
end
def self.bang(method)
@@ -80,7 +78,7 @@ module Spec
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ")
- setup = "require '#{lib}/bundler' ; Bundler.setup(#{groups})\n"
+ setup = "require '#{lib}/bundler' ; Bundler.ui.silence { Bundler.setup(#{groups}) }\n"
ruby(setup + cmd, opts)
end
bang :run