From 99fad7797cccc7b141389cda3f34c61d396044cb Mon Sep 17 00:00:00 2001 From: thibhero Date: Thu, 6 Mar 2025 21:27:13 -0500 Subject: [PATCH] modifying files with brew style --- Library/Homebrew/cmd/install.rb | 4 +-- Library/Homebrew/cmd/reinstall.rb | 4 +-- Library/Homebrew/cmd/upgrade.rb | 4 +-- Library/Homebrew/install.rb | 7 ++-- Library/Homebrew/test/cmd/install_spec.rb | 12 +++---- .../spec/shared_context/integration_test.rb | 34 +++++++++---------- 6 files changed, 28 insertions(+), 37 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index b93b0f6397..d6b29fea44 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -307,9 +307,7 @@ module Homebrew Install.perform_preinstall_checks_once Install.check_cc_argv(args.cc) - if args.ask? - Install.ask(formulae, args: args) - end + Install.ask(formulae, args: args) if args.ask? Install.install_formulae( installed_formulae, diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 094936dd3f..4556222e1c 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -132,9 +132,7 @@ module Homebrew Install.perform_preinstall_checks_once # Main block: if asking the user is enabled, show dependency and size information. - if args.ask? - Install.ask(formulae, args: args) - end + Install.ask(formulae, args: args) if args.ask? formulae.each do |formula| if formula.pinned? diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index c33c7c7bf4..b48ace323d 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -222,9 +222,7 @@ module Homebrew Install.perform_preinstall_checks_once # Main block: if asking the user is enabled, show dependency and size information. - if args.ask? - Install.ask(formulae_to_install, args: args) - end + Install.ask(formulae_to_install, args: args) if args.ask? Upgrade.upgrade_formulae( formulae_to_install, diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 37a42ccd3b..c7a0b41aff 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -327,7 +327,6 @@ module Homebrew puts formula_names.join(" ") end - # Main block: if asking the user is enabled, show dependency and size information. def ask(formulae, args:) ohai "Looking for bottles..." @@ -335,8 +334,9 @@ module Homebrew sized_formulae = compute_sized_formulae(formulae, args: args) sizes = compute_total_sizes(sized_formulae, debug: args.debug?) - puts "#{::Utils.pluralize("Formul", sized_formulae.count, plural: "ae", - singular: "a")} (#{sized_formulae.count}): #{sized_formulae.join(", ")}\n\n" + puts "#{::Utils.pluralize("Formul", sized_formulae.count, plural: "ae", + singular: "a")} (#{sized_formulae.count}): \ + #{sized_formulae.join(", ")}\n\n" puts "Download Size: #{disk_usage_readable(sizes[:download])}" puts "Install Size: #{disk_usage_readable(sizes[:installed])}" 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:) end - def ask_input ohai "Do you want to proceed with the installation? [Y/y/yes/N/n]" accepted_inputs = %w[y yes] diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index 5cea09d32b..460c465c76 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -89,10 +89,9 @@ RSpec.describe Homebrew::Cmd::InstallCmd do it "installs with asking for user prompts without installed dependent checks", :integration_test do setup_test_formula "testball1" - expect { + expect do brew "install", "--ask", "testball1" - }.to output(/.*Formula\s*\(1\):\s*testball1.*/ - ).to_stdout.and not_to_output.to_stderr + end.to output(/.*Formula\s*\(1\):\s*testball1.*/).to_stdout.and not_to_output.to_stderr expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file end @@ -108,8 +107,7 @@ RSpec.describe Homebrew::Cmd::InstallCmd do setup_test_formula "testball5", <<~RUBY depends_on "testball4" RUBY - setup_test_formula "testball4", <<~RUBY - RUBY + setup_test_formula "testball4", "" setup_test_formula "hiop" setup_test_formula "build" @@ -120,8 +118,8 @@ RSpec.describe Homebrew::Cmd::InstallCmd do expect { brew "install", "--ask", "testball1" - }.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball5\s*,?\s*testball4.*/ - ).to_stdout.and not_to_output.to_stderr + }.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball5\s*,?\s*testball4.*/).to_stdout + .and not_to_output.to_stderr expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index d205f2f005..f8f3b0f60a 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -146,29 +146,29 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin program_name = "test" 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}" content = <<~RUBY - desc "Some test" - homepage "https://brew.sh/#{name}" - url "file://#{tarball}" - sha256 "#{tarball.sha256}" + desc "Some test" + homepage "https://brew.sh/#{name}" + url "file://#{tarball}" + sha256 "#{tarball.sha256}" - option "with-foo", "Build with foo" - #{bottle_block} - def install - (prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo" - prefix.install Dir["*"] - (buildpath/"#{program_name}.c").write \ - "#include \\nint main(){printf(\\"#{program_name}\\");return 0;}" - bin.mkpath - system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}" - end + option "with-foo", "Build with foo" + #{bottle_block} + def install + (prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo" + prefix.install Dir["*"] + (buildpath/"#{program_name}.c").write \ + "#include \\nint main(){printf(\\"#{program_name}\\");return 0;}" + bin.mkpath + system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}" + end - #{content} + #{content} - # something here + # something here RUBY when "bar" content = <<~RUBY