summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Brictson <[email protected]>2024-08-22 17:14:01 -0700
committergit <[email protected]>2024-08-26 14:56:26 +0000
commit20664826840f1ae1ba83c97764996a71105212e5 (patch)
tree68fb60fbb4109653a25ff352de790312b6d76057
parentcfad1f95d50c76cf66b8539a34b67cb72323848e (diff)
[rubygems/rubygems] Fix newline=false being ignored by Shell#warn
https://github.com/rubygems/rubygems/commit/e021ff33a8
-rw-r--r--lib/bundler/retry.rb2
-rw-r--r--lib/bundler/ui/shell.rb2
-rw-r--r--spec/bundler/bundler/retry_spec.rb2
-rw-r--r--spec/bundler/bundler/ui/shell_spec.rb5
4 files changed, 7 insertions, 4 deletions
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index b95c42c361..090cb7e2ca 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -50,7 +50,7 @@ module Bundler
end
return true unless name
Bundler.ui.info "" unless Bundler.ui.debug? # Add new line in case dots preceded this
- Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
+ Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", true
end
def keep_trying?
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 899f3dcb87..16e7cc70b5 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -130,7 +130,7 @@ module Bundler
def tell_err(message, color = nil, newline = nil)
return if @shell.send(:stderr).closed?
- newline ||= !message.to_s.match?(/( |\t)\Z/)
+ newline = !message.to_s.match?(/( |\t)\Z/) if newline.nil?
message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
color = nil if color && !$stderr.tty?
diff --git a/spec/bundler/bundler/retry_spec.rb b/spec/bundler/bundler/retry_spec.rb
index b893580d72..ffbc078074 100644
--- a/spec/bundler/bundler/retry_spec.rb
+++ b/spec/bundler/bundler/retry_spec.rb
@@ -68,7 +68,7 @@ RSpec.describe Bundler::Retry do
it "print error message with newlines" do
allow(Bundler.ui).to receive(:debug?).and_return(false)
expect(Bundler.ui).to receive(:info).with("").twice
- expect(Bundler.ui).to receive(:warn).with(failure_message, false)
+ expect(Bundler.ui).to receive(:warn).with(failure_message, true)
expect do
Bundler::Retry.new("test", [], 1).attempt do
diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb
index 15120a8a41..e1340e5923 100644
--- a/spec/bundler/bundler/ui/shell_spec.rb
+++ b/spec/bundler/bundler/ui/shell_spec.rb
@@ -21,9 +21,12 @@ RSpec.describe Bundler::UI::Shell do
describe "#warn" do
before { subject.level = "warn" }
- it "prints to stderr" do
+ it "prints to stderr, implicitly adding a newline" do
expect { subject.warn("warning") }.to output("warning\n").to_stderr
end
+ it "can be told not to emit a newline" do
+ expect { subject.warn("warning", false) }.to output("warning").to_stderr
+ end
end
describe "#debug" do