Skip to content

Commit 0c969c2

Browse files
authored
Merge pull request #20311 from Homebrew/quieter_debug
Make `--debug` output a bit quieter by default
2 parents 3562adb + 312f046 commit 0c969c2

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Library/Homebrew/cask/cask_loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def self.for(ref, need_path: false, warn: true)
622622
NullLoader,
623623
].each do |loader_class|
624624
if (loader = loader_class.try_new(ref, warn:))
625-
$stderr.puts "#{$PROGRAM_NAME} (#{loader.class}): loading #{ref}" if debug?
625+
$stderr.puts "#{$PROGRAM_NAME} (#{loader.class}): loading #{ref}" if verbose? && debug?
626626
return loader
627627
end
628628
end

Library/Homebrew/formulary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ def self.loader_for(ref, from: nil, warn: true)
11591159
NullLoader,
11601160
].each do |loader_class|
11611161
if (loader = loader_class.try_new(ref, from:, warn:))
1162-
$stderr.puts "#{$PROGRAM_NAME} (#{loader_class}): loading #{ref}" if debug?
1162+
$stderr.puts "#{$PROGRAM_NAME} (#{loader_class}): loading #{ref}" if verbose? && debug?
11631163
return loader
11641164
end
11651165
end

Library/Homebrew/system_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.run!(command, **options)
4444

4545
sig { returns(SystemCommand::Result) }
4646
def run!
47-
$stderr.puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? || debug?
47+
$stderr.puts redact_secrets(command.shelljoin.gsub('\=', "="), @secrets) if verbose? && debug?
4848

4949
@output = []
5050

@@ -104,7 +104,7 @@ def initialize(
104104
print_stdout: false,
105105
print_stderr: true,
106106
debug: nil,
107-
verbose: false,
107+
verbose: T.unsafe(nil),
108108
secrets: [],
109109
chdir: T.unsafe(nil),
110110
reset_uid: false,

Library/Homebrew/test/system_command_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
.and not_to_output.to_stdout
194194
end
195195

196-
context "when `debug?` is true" do
196+
context "when `verbose?` and `debug?` are true" do
197197
include Context
198198

199199
let(:options) do
@@ -203,8 +203,8 @@
203203
] }
204204
end
205205

206-
it "echoes the command and all output to STDERR when `debug?` is true" do
207-
with_context debug: true do
206+
it "echoes the command and all output to STDERR" do
207+
with_context(verbose: true, debug: true) do
208208
expect { described_class.run(command, **options) }
209209
.to output(/\A.*#{Regexp.escape(command)}.*\n1\n2\n3\n4\n5\n6\n\Z/).to_stderr
210210
.and not_to_output.to_stdout
@@ -323,6 +323,7 @@
323323
described_class.run! "curl",
324324
args: %w[--user username:hunter2],
325325
verbose: true,
326+
debug: true,
326327
secrets: %w[hunter2]
327328
end.to raise_error(ErrorDuringExecution, redacted_msg).and output(redacted_msg).to_stderr
328329
end
@@ -333,6 +334,7 @@
333334
ENV["PASSWORD"] = "hunter2"
334335
described_class.run! "curl",
335336
args: %w[--user username:hunter2],
337+
debug: true,
336338
verbose: true
337339
end.to raise_error(ErrorDuringExecution, redacted_msg).and output(redacted_msg).to_stderr
338340
end

0 commit comments

Comments
 (0)