modifying files with brew style

This commit is contained in:
thibhero 2025-03-06 21:27:13 -05:00
parent f4d93e19b8
commit 99fad7797c
6 changed files with 28 additions and 37 deletions

View File

@ -307,9 +307,7 @@ module Homebrew
Install.perform_preinstall_checks_once Install.perform_preinstall_checks_once
Install.check_cc_argv(args.cc) Install.check_cc_argv(args.cc)
if args.ask? Install.ask(formulae, args: args) if args.ask?
Install.ask(formulae, args: args)
end
Install.install_formulae( Install.install_formulae(
installed_formulae, installed_formulae,

View File

@ -132,9 +132,7 @@ module Homebrew
Install.perform_preinstall_checks_once Install.perform_preinstall_checks_once
# Main block: if asking the user is enabled, show dependency and size information. # Main block: if asking the user is enabled, show dependency and size information.
if args.ask? Install.ask(formulae, args: args) if args.ask?
Install.ask(formulae, args: args)
end
formulae.each do |formula| formulae.each do |formula|
if formula.pinned? if formula.pinned?

View File

@ -222,9 +222,7 @@ module Homebrew
Install.perform_preinstall_checks_once Install.perform_preinstall_checks_once
# Main block: if asking the user is enabled, show dependency and size information. # Main block: if asking the user is enabled, show dependency and size information.
if args.ask? Install.ask(formulae_to_install, args: args) if args.ask?
Install.ask(formulae_to_install, args: args)
end
Upgrade.upgrade_formulae( Upgrade.upgrade_formulae(
formulae_to_install, formulae_to_install,

View File

@ -327,7 +327,6 @@ module Homebrew
puts formula_names.join(" ") puts formula_names.join(" ")
end end
# Main block: if asking the user is enabled, show dependency and size information. # Main block: if asking the user is enabled, show dependency and size information.
def ask(formulae, args:) def ask(formulae, args:)
ohai "Looking for bottles..." ohai "Looking for bottles..."
@ -335,8 +334,9 @@ module Homebrew
sized_formulae = compute_sized_formulae(formulae, args: args) sized_formulae = compute_sized_formulae(formulae, args: args)
sizes = compute_total_sizes(sized_formulae, debug: args.debug?) sizes = compute_total_sizes(sized_formulae, debug: args.debug?)
puts "#{::Utils.pluralize("Formul", sized_formulae.count, plural: "ae", puts "#{::Utils.pluralize("Formul", sized_formulae.count, plural: "ae",
singular: "a")} (#{sized_formulae.count}): #{sized_formulae.join(", ")}\n\n" singular: "a")} (#{sized_formulae.count}): \
#{sized_formulae.join(", ")}\n\n"
puts "Download Size: #{disk_usage_readable(sizes[:download])}" puts "Download Size: #{disk_usage_readable(sizes[:download])}"
puts "Install Size: #{disk_usage_readable(sizes[:installed])}" puts "Install Size: #{disk_usage_readable(sizes[:installed])}"
puts "Net Install Size: #{disk_usage_readable(sizes[:net])}" if sizes[:net] != 0 puts "Net Install Size: #{disk_usage_readable(sizes[:net])}" if sizes[:net] != 0
@ -381,7 +381,6 @@ module Homebrew
Upgrade.install_formula(formula_installer, upgrade:) Upgrade.install_formula(formula_installer, upgrade:)
end end
def ask_input def ask_input
ohai "Do you want to proceed with the installation? [Y/y/yes/N/n]" ohai "Do you want to proceed with the installation? [Y/y/yes/N/n]"
accepted_inputs = %w[y yes] accepted_inputs = %w[y yes]

View File

@ -89,10 +89,9 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
it "installs with asking for user prompts without installed dependent checks", :integration_test do it "installs with asking for user prompts without installed dependent checks", :integration_test do
setup_test_formula "testball1" setup_test_formula "testball1"
expect { expect do
brew "install", "--ask", "testball1" brew "install", "--ask", "testball1"
}.to output(/.*Formula\s*\(1\):\s*testball1.*/ end.to output(/.*Formula\s*\(1\):\s*testball1.*/).to_stdout.and not_to_output.to_stderr
).to_stdout.and not_to_output.to_stderr
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
end end
@ -108,8 +107,7 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
setup_test_formula "testball5", <<~RUBY setup_test_formula "testball5", <<~RUBY
depends_on "testball4" depends_on "testball4"
RUBY RUBY
setup_test_formula "testball4", <<~RUBY setup_test_formula "testball4", ""
RUBY
setup_test_formula "hiop" setup_test_formula "hiop"
setup_test_formula "build" setup_test_formula "build"
@ -120,8 +118,8 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
expect { expect {
brew "install", "--ask", "testball1" brew "install", "--ask", "testball1"
}.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball5\s*,?\s*testball4.*/ }.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball5\s*,?\s*testball4.*/).to_stdout
).to_stdout.and not_to_output.to_stderr .and not_to_output.to_stderr
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file

View File

@ -146,29 +146,29 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
program_name = "test" program_name = "test"
end end
tarball_name = "#{prefix}-0.1#{'-linux' if OS.linux?}.tbz" tarball_name = "#{prefix}-0.1#{"-linux" if OS.linux?}.tbz"
tarball = TEST_FIXTURE_DIR / "tarballs/#{tarball_name}" tarball = TEST_FIXTURE_DIR / "tarballs/#{tarball_name}"
content = <<~RUBY content = <<~RUBY
desc "Some test" desc "Some test"
homepage "https://brew.sh/#{name}" homepage "https://brew.sh/#{name}"
url "file://#{tarball}" url "file://#{tarball}"
sha256 "#{tarball.sha256}" sha256 "#{tarball.sha256}"
option "with-foo", "Build with foo" option "with-foo", "Build with foo"
#{bottle_block} #{bottle_block}
def install def install
(prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo" (prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo"
prefix.install Dir["*"] prefix.install Dir["*"]
(buildpath/"#{program_name}.c").write \ (buildpath/"#{program_name}.c").write \
"#include <stdio.h>\\nint main(){printf(\\"#{program_name}\\");return 0;}" "#include <stdio.h>\\nint main(){printf(\\"#{program_name}\\");return 0;}"
bin.mkpath bin.mkpath
system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}" system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}"
end end
#{content} #{content}
# something here # something here
RUBY RUBY
when "bar" when "bar"
content = <<~RUBY content = <<~RUBY