Fix RuboCop failures.
Co-authored-by: Patrick Linnane <patrick@linnane.io> Co-authored-by: Carlo Cabrera <github@carlo.cab> Co-authored-by: Thierry Moisan <thierry.moisan@gmail.com> Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
6a5a48de29
commit
4513a43d53
@ -216,6 +216,10 @@ Naming/MethodParameterName:
|
||||
merge:
|
||||
- AllowedNames
|
||||
|
||||
# Allows a nicer API for boolean methods with side effects.
|
||||
Naming/PredicateMethod:
|
||||
AllowBangMethods: true
|
||||
|
||||
# Both styles are used depending on context,
|
||||
# e.g. `sha256` and `something_countable_1`.
|
||||
Naming/VariableNumber:
|
||||
|
||||
@ -10,7 +10,13 @@ Homebrew/MoveToExtendOS:
|
||||
- "{extend,test,requirements}/**/*"
|
||||
- "os.rb"
|
||||
|
||||
Naming/PredicateName:
|
||||
# We don't use Sorbet for RSpec tests so let's disable this there.
|
||||
Sorbet/BlockMethodDefinition:
|
||||
Exclude:
|
||||
- test/**/*
|
||||
|
||||
# Want to preserve our own API for these methods for now.
|
||||
Naming/PredicatePrefix:
|
||||
inherit_mode:
|
||||
merge:
|
||||
- AllowedMethods
|
||||
|
||||
@ -142,7 +142,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { params(names: T::Array[String], type: String, regenerate: T::Boolean).returns(T::Boolean) }
|
||||
def self.write_names_file(names, type, regenerate:)
|
||||
def self.write_names_file!(names, type, regenerate:)
|
||||
names_path = HOMEBREW_CACHE_API/"#{type}_names.txt"
|
||||
if !names_path.exist? || regenerate
|
||||
names_path.write(names.join("\n"))
|
||||
|
||||
@ -28,7 +28,7 @@ module Homebrew
|
||||
|
||||
sig { params(cask: ::Cask::Cask).returns(::Cask::Cask) }
|
||||
def self.source_download(cask)
|
||||
path = cask.ruby_source_path.to_s || "Casks/#{cask.token}.rb"
|
||||
path = cask.ruby_source_path.to_s
|
||||
sha256 = cask.ruby_source_checksum[:sha256]
|
||||
checksum = Checksum.new(sha256) if sha256
|
||||
git_head = cask.tap_git_head || "HEAD"
|
||||
@ -95,7 +95,7 @@ module Homebrew
|
||||
def self.write_names(regenerate: false)
|
||||
download_and_cache_data! unless cache.key?("casks")
|
||||
|
||||
Homebrew::API.write_names_file(all_casks.keys, "cask", regenerate:)
|
||||
Homebrew::API.write_names_file!(all_casks.keys, "cask", regenerate:)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -129,7 +129,7 @@ module Homebrew
|
||||
def self.write_names_and_aliases(regenerate: false)
|
||||
download_and_cache_data! unless cache.key?("formulae")
|
||||
|
||||
return unless Homebrew::API.write_names_file(all_formulae.keys, "formula", regenerate:)
|
||||
return unless Homebrew::API.write_names_file!(all_formulae.keys, "formula", regenerate:)
|
||||
|
||||
(HOMEBREW_CACHE_API/"formula_aliases.txt").open("w") do |file|
|
||||
all_aliases.each do |alias_name, real_name|
|
||||
|
||||
@ -91,7 +91,7 @@ class Bottle
|
||||
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
|
||||
resource.fetch(verify_download_integrity:, timeout:, quiet:)
|
||||
rescue DownloadError
|
||||
raise unless fallback_on_error
|
||||
raise unless fallback_on_error?
|
||||
|
||||
fetch_tab
|
||||
retry
|
||||
@ -121,7 +121,7 @@ class Bottle
|
||||
begin
|
||||
resource.fetch(timeout:, quiet:)
|
||||
rescue DownloadError
|
||||
raise unless fallback_on_error
|
||||
raise unless fallback_on_error?
|
||||
|
||||
retry
|
||||
rescue Resource::BottleManifest::Error
|
||||
@ -193,7 +193,7 @@ class Bottle
|
||||
specs
|
||||
end
|
||||
|
||||
def fallback_on_error
|
||||
def fallback_on_error?
|
||||
# Use the default bottle domain as a fallback mirror
|
||||
if @resource.url.start_with?(Homebrew::EnvConfig.bottle_domain) &&
|
||||
Homebrew::EnvConfig.bottle_domain != HOMEBREW_BOTTLE_DEFAULT_DOMAIN
|
||||
|
||||
@ -41,7 +41,7 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def mas_installed?
|
||||
@mas_installed ||= which_formula("mas")
|
||||
@mas_installed ||= which_formula?("mas")
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
@ -59,7 +59,7 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def whalebrew_installed?
|
||||
@whalebrew_installed ||= which_formula("whalebrew")
|
||||
@whalebrew_installed ||= which_formula?("whalebrew")
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
@ -70,7 +70,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { params(name: String).returns(T::Boolean) }
|
||||
def which_formula(name)
|
||||
def which_formula?(name)
|
||||
formula = Formulary.factory(name)
|
||||
ENV["PATH"] = "#{formula.opt_bin}:#{ENV.fetch("PATH", nil)}" if formula.any_version_installed?
|
||||
which(name).present?
|
||||
|
||||
@ -18,7 +18,7 @@ module Homebrew
|
||||
Homebrew::Bundle::CaskDumper.cask_is_outdated_using_greedy?(name)
|
||||
end
|
||||
|
||||
def self.preinstall(name, no_upgrade: false, verbose: false, **options)
|
||||
def self.preinstall!(name, no_upgrade: false, verbose: false, **options)
|
||||
if installed_casks.include?(name) && !upgrading?(no_upgrade, name, options)
|
||||
puts "Skipping install of #{name} cask. It is already installed." if verbose
|
||||
return false
|
||||
@ -27,7 +27,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
return true unless preinstall
|
||||
|
||||
full_name = options.fetch(:full_name, name)
|
||||
|
||||
@ -37,12 +37,12 @@ module Homebrew
|
||||
if casks.any?
|
||||
args = zap ? ["--zap"] : []
|
||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--cask", *args, "--force", *casks
|
||||
puts "Uninstalled #{casks.size} cask#{(casks.size == 1) ? "" : "s"}"
|
||||
puts "Uninstalled #{casks.size} cask#{"s" if casks.size != 1}"
|
||||
end
|
||||
|
||||
if formulae.any?
|
||||
Kernel.system HOMEBREW_BREW_FILE, "uninstall", "--formula", "--force", *formulae
|
||||
puts "Uninstalled #{formulae.size} formula#{(formulae.size == 1) ? "" : "e"}"
|
||||
puts "Uninstalled #{formulae.size} formula#{"e" if formulae.size != 1}"
|
||||
end
|
||||
|
||||
Kernel.system HOMEBREW_BREW_FILE, "untap", *taps if taps.any?
|
||||
|
||||
@ -11,7 +11,7 @@ module Homebrew
|
||||
def self.run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
||||
quiet: false)
|
||||
@dsl = Brewfile.read(global:, file:)
|
||||
Homebrew::Bundle::Installer.install(
|
||||
Homebrew::Bundle::Installer.install!(
|
||||
@dsl.entries,
|
||||
global:, file:, no_lock:, no_upgrade:, verbose:, force:, quiet:,
|
||||
) || exit(1)
|
||||
|
||||
@ -10,12 +10,12 @@ module Homebrew
|
||||
@pinned_formulae = nil
|
||||
end
|
||||
|
||||
def self.preinstall(name, no_upgrade: false, verbose: false, **options)
|
||||
new(name, options).preinstall(no_upgrade:, verbose:)
|
||||
def self.preinstall!(name, no_upgrade: false, verbose: false, **options)
|
||||
new(name, options).preinstall!(no_upgrade:, verbose:)
|
||||
end
|
||||
|
||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
new(name, options).install(preinstall:, no_upgrade:, verbose:, force:)
|
||||
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
new(name, options).install!(preinstall:, no_upgrade:, verbose:, force:)
|
||||
end
|
||||
|
||||
def initialize(name, options = {})
|
||||
@ -31,7 +31,7 @@ module Homebrew
|
||||
@changed = nil
|
||||
end
|
||||
|
||||
def preinstall(no_upgrade: false, verbose: false)
|
||||
def preinstall!(no_upgrade: false, verbose: false)
|
||||
if installed? && (self.class.no_upgrade_with_args?(no_upgrade, @name) || !upgradable?)
|
||||
puts "Skipping install of #{@name} formula. It is already installed." if verbose
|
||||
@changed = nil
|
||||
@ -41,7 +41,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
def install!(preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
install_result = if preinstall
|
||||
install_change_state!(no_upgrade:, verbose:, force:)
|
||||
else
|
||||
@ -80,9 +80,9 @@ module Homebrew
|
||||
return false unless resolve_conflicts!(verbose:)
|
||||
|
||||
if installed?
|
||||
upgrade!(verbose:, force:)
|
||||
upgrade_formula!(verbose:, force:)
|
||||
else
|
||||
install!(verbose:, force:)
|
||||
install_formula!(verbose:, force:)
|
||||
end
|
||||
end
|
||||
|
||||
@ -282,7 +282,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install!(verbose:, force:)
|
||||
def install_formula!(verbose:, force:)
|
||||
install_args = @args.dup
|
||||
install_args << "--force" << "--overwrite" if force
|
||||
install_args << "--skip-link" if @link == false
|
||||
@ -298,7 +298,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def upgrade!(verbose:, force:)
|
||||
def upgrade_formula!(verbose:, force:)
|
||||
upgrade_args = []
|
||||
upgrade_args << "--force" if force
|
||||
with_args = " with #{upgrade_args.join(" ")}" if upgrade_args.present?
|
||||
|
||||
@ -13,8 +13,8 @@ require "bundle/skipper"
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Installer
|
||||
def self.install(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
|
||||
force: false, quiet: false)
|
||||
def self.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
|
||||
force: false, quiet: false)
|
||||
success = 0
|
||||
failure = 0
|
||||
|
||||
@ -49,7 +49,7 @@ module Homebrew
|
||||
next if cls.nil?
|
||||
next if Homebrew::Bundle::Skipper.skip? entry
|
||||
|
||||
preinstall = if cls.preinstall(*args, **options, no_upgrade:, verbose:)
|
||||
preinstall = if cls.preinstall!(*args, **options, no_upgrade:, verbose:)
|
||||
puts Formatter.success("#{verb} #{name}")
|
||||
true
|
||||
else
|
||||
@ -57,7 +57,7 @@ module Homebrew
|
||||
false
|
||||
end
|
||||
|
||||
if cls.install(*args, **options,
|
||||
if cls.install!(*args, **options,
|
||||
preinstall:, no_upgrade:, verbose:, force:)
|
||||
success += 1
|
||||
else
|
||||
|
||||
@ -11,7 +11,7 @@ module Homebrew
|
||||
@outdated_app_ids = nil
|
||||
end
|
||||
|
||||
def self.preinstall(name, id, no_upgrade: false, verbose: false)
|
||||
def self.preinstall!(name, id, no_upgrade: false, verbose: false)
|
||||
unless Bundle.mas_installed?
|
||||
puts "Installing mas. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "mas", verbose:)
|
||||
@ -27,7 +27,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def self.install(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
def self.install!(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
return true unless preinstall
|
||||
|
||||
if app_id_installed?(id)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module TapInstaller
|
||||
def self.preinstall(name, verbose: false, **_options)
|
||||
def self.preinstall!(name, verbose: false, **_options)
|
||||
if installed_taps.include? name
|
||||
puts "Skipping install of #{name} tap. It is already installed." if verbose
|
||||
return false
|
||||
@ -13,7 +13,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def self.install(name, preinstall: true, verbose: false, force: false, **options)
|
||||
def self.install!(name, preinstall: true, verbose: false, force: false, **options)
|
||||
return true unless preinstall
|
||||
|
||||
puts "Installing #{name} tap. It is not currently installed." if verbose
|
||||
|
||||
@ -8,7 +8,7 @@ module Homebrew
|
||||
@installed_extensions = nil
|
||||
end
|
||||
|
||||
def self.preinstall(name, no_upgrade: false, verbose: false)
|
||||
def self.preinstall!(name, no_upgrade: false, verbose: false)
|
||||
if !Bundle.vscode_installed? && Bundle.cask_installed?
|
||||
puts "Installing visual-studio-code. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "--cask", "visual-studio-code", verbose:)
|
||||
@ -24,7 +24,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
return true unless preinstall
|
||||
return true if extension_installed?(name)
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ module Homebrew
|
||||
@installed_images = nil
|
||||
end
|
||||
|
||||
def self.preinstall(name, verbose: false, **_options)
|
||||
def self.preinstall!(name, verbose: false, **_options)
|
||||
unless Bundle.whalebrew_installed?
|
||||
puts "Installing whalebrew. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "--formula", "whalebrew", verbose:)
|
||||
@ -23,7 +23,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def self.install(name, preinstall: true, verbose: false, force: false, **_options)
|
||||
def self.install!(name, preinstall: true, verbose: false, force: false, **_options)
|
||||
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
||||
return true unless preinstall
|
||||
|
||||
|
||||
@ -189,7 +189,7 @@ on_request: true)
|
||||
when :deprecated
|
||||
opoo message_full
|
||||
when :disabled
|
||||
GitHub::Actions.puts_annotation_if_env_set(:error, message)
|
||||
GitHub::Actions.puts_annotation_if_env_set!(:error, message)
|
||||
raise CaskCannotBeInstalledError.new(@cask, message)
|
||||
end
|
||||
end
|
||||
|
||||
@ -23,7 +23,7 @@ module Cask
|
||||
require_sha: T.nilable(T::Boolean),
|
||||
).returns(T::Boolean)
|
||||
}
|
||||
def self.upgrade_casks(
|
||||
def self.upgrade_casks!(
|
||||
*casks,
|
||||
args:,
|
||||
force: false,
|
||||
@ -134,7 +134,7 @@ module Cask
|
||||
|
||||
return true if caught_exceptions.empty?
|
||||
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
||||
raise caught_exceptions.fetch(0) if caught_exceptions.count == 1
|
||||
raise caught_exceptions.fetch(0) if caught_exceptions.one?
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
@ -194,7 +194,7 @@ class Caveats
|
||||
startup = formula.service.requires_root?
|
||||
if Utils::Service.running?(formula)
|
||||
s << "To restart #{formula.full_name} after an upgrade:"
|
||||
s << " #{startup ? "sudo " : ""}brew services restart #{formula.full_name}"
|
||||
s << " #{"sudo " if startup}brew services restart #{formula.full_name}"
|
||||
elsif startup
|
||||
s << "To start #{formula.full_name} now and restart at startup:"
|
||||
s << " sudo brew services start #{formula.full_name}"
|
||||
|
||||
@ -259,7 +259,7 @@ module Homebrew
|
||||
if !Homebrew::EnvConfig.no_install_upgrade? && installed_casks.any?
|
||||
require "cask/upgrade"
|
||||
|
||||
Cask::Upgrade.upgrade_casks(
|
||||
Cask::Upgrade.upgrade_casks!(
|
||||
*installed_casks,
|
||||
force: args.force?,
|
||||
dry_run: args.dry_run?,
|
||||
|
||||
@ -52,8 +52,8 @@ module Homebrew
|
||||
|
||||
version = Keg.new(path).version
|
||||
major_version = version.major.to_i
|
||||
minor_version = version.minor.to_i || 0
|
||||
patch_version = version.patch.to_i || 0
|
||||
minor_version = version.minor.to_i
|
||||
patch_version = version.patch.to_i
|
||||
|
||||
minor_version_range, patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
||||
# Only create symlinks for the exact installed patch version.
|
||||
|
||||
@ -53,7 +53,7 @@ module Homebrew
|
||||
version = Keg.new(path).version
|
||||
major_version = version.major.to_i
|
||||
minor_version = version.minor.to_i
|
||||
patch_version = version.patch.to_i || 0
|
||||
patch_version = version.patch.to_i
|
||||
|
||||
patch_version_range = if Homebrew::EnvConfig.env_sync_strict?
|
||||
# Only create symlinks for the exact installed patch version.
|
||||
|
||||
@ -65,7 +65,7 @@ module Homebrew
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
return if search_package_manager
|
||||
return if search_package_manager!
|
||||
|
||||
query = args.named.join(" ")
|
||||
string_or_regex = Search.query_regexp(query)
|
||||
@ -108,7 +108,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def search_package_manager
|
||||
def search_package_manager!
|
||||
package_manager = PACKAGE_MANAGERS.find { |name,| args.public_send(:"#{name}?") }
|
||||
return false if package_manager.nil?
|
||||
|
||||
|
||||
@ -137,8 +137,8 @@ module Homebrew
|
||||
|
||||
formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled?
|
||||
|
||||
upgrade_outdated_formulae(formulae) unless only_upgrade_casks
|
||||
upgrade_outdated_casks(casks) unless only_upgrade_formulae
|
||||
upgrade_outdated_formulae!(formulae) unless only_upgrade_casks
|
||||
upgrade_outdated_casks!(casks) unless only_upgrade_formulae
|
||||
|
||||
Cleanup.periodic_clean!(dry_run: args.dry_run?)
|
||||
|
||||
@ -148,7 +148,7 @@ module Homebrew
|
||||
private
|
||||
|
||||
sig { params(formulae: T::Array[Formula]).returns(T::Boolean) }
|
||||
def upgrade_outdated_formulae(formulae)
|
||||
def upgrade_outdated_formulae!(formulae)
|
||||
return false if args.cask?
|
||||
|
||||
if args.build_from_source?
|
||||
@ -280,12 +280,12 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { params(casks: T::Array[Cask::Cask]).returns(T::Boolean) }
|
||||
def upgrade_outdated_casks(casks)
|
||||
def upgrade_outdated_casks!(casks)
|
||||
return false if args.formula?
|
||||
|
||||
Install.ask_casks casks if args.ask?
|
||||
|
||||
Cask::Upgrade.upgrade_casks(
|
||||
Cask::Upgrade.upgrade_casks!(
|
||||
*casks,
|
||||
force: args.force?,
|
||||
greedy: args.greedy?,
|
||||
|
||||
@ -723,7 +723,7 @@ module Homebrew
|
||||
all_bottle = !args.no_all_checks? &&
|
||||
(!old_bottle_spec_matches || bottle.rebuild != old_bottle_spec.rebuild) &&
|
||||
tag_hashes.count > 1 &&
|
||||
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.count == 1
|
||||
tag_hashes.uniq { |tag_hash| "#{tag_hash["cellar"]}-#{tag_hash["sha256"]}" }.one?
|
||||
|
||||
old_all_bottle = old_bottle_spec.tag?(Utils::Bottles.tag(:all))
|
||||
if !all_bottle && old_all_bottle && !args.no_all_checks?
|
||||
|
||||
@ -589,7 +589,7 @@ module Homebrew
|
||||
#{leading_spaces}resource "#{resource.name}" do
|
||||
#{leading_spaces} url "#{new_url}"#{new_mirrors.map { |m| "\n#{leading_spaces} mirror \"#{m}\"" }.join}
|
||||
#{leading_spaces} sha256 "#{new_hash}"
|
||||
#{forced_version ? "#{leading_spaces} version \"#{version}\"\n" : ""}
|
||||
#{"#{leading_spaces} version \"#{version}\"\n" if forced_version}
|
||||
#{leading_spaces} livecheck do
|
||||
#{leading_spaces} formula :parent
|
||||
#{leading_spaces} end
|
||||
|
||||
@ -180,7 +180,7 @@ module Homebrew
|
||||
|
||||
formulae_and_casks.each_with_index do |formula_or_cask, i|
|
||||
puts if i.positive?
|
||||
next if skip_ineligible_formulae(formula_or_cask)
|
||||
next if skip_ineligible_formulae!(formula_or_cask)
|
||||
|
||||
use_full_name = args.full_name? || ambiguous_names.include?(formula_or_cask)
|
||||
name = Livecheck.package_or_resource_name(formula_or_cask, full_name: use_full_name)
|
||||
@ -204,7 +204,7 @@ module Homebrew
|
||||
sig {
|
||||
params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T::Boolean)
|
||||
}
|
||||
def skip_ineligible_formulae(formula_or_cask)
|
||||
def skip_ineligible_formulae!(formula_or_cask)
|
||||
if formula_or_cask.is_a?(Formula)
|
||||
skip = formula_or_cask.disabled? || formula_or_cask.head_only?
|
||||
name = formula_or_cask.name
|
||||
|
||||
@ -587,7 +587,7 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
def __check_linked_brew(formula)
|
||||
def __check_linked_brew!(formula)
|
||||
formula.installed_prefixes.each do |prefix|
|
||||
prefix.find do |src|
|
||||
next if src == prefix
|
||||
|
||||
@ -341,7 +341,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
|
||||
.reject { |path| path.extname.end_with?(".incomplete") }
|
||||
|
||||
@cached_location = T.let(
|
||||
if downloads.count == 1
|
||||
if downloads.one?
|
||||
downloads.fetch(0)
|
||||
else
|
||||
HOMEBREW_CACHE/"downloads/#{url_sha256}--#{Utils.safe_filename(resolved_basename)}"
|
||||
|
||||
@ -20,11 +20,11 @@ class File
|
||||
# file.write('hello')
|
||||
# end
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
type_parameters(:Out).params(
|
||||
file_name: T.any(Pathname, String),
|
||||
temp_dir: String,
|
||||
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:out)),
|
||||
).returns(T.type_parameter(:out))
|
||||
_block: T.proc.params(arg0: Tempfile).returns(T.type_parameter(:Out)),
|
||||
).returns(T.type_parameter(:Out))
|
||||
}
|
||||
def self.atomic_write(file_name, temp_dir = dirname(file_name), &_block)
|
||||
require "tempfile" unless defined?(Tempfile)
|
||||
|
||||
@ -3,18 +3,18 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:k2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
||||
type_parameters(:K2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||
}
|
||||
def deep_merge(other_hash, &block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:k2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:k2), T.untyped],
|
||||
type_parameters(:K2).params(
|
||||
other_hash: T::Hash[T.type_parameter(:K2), T.untyped],
|
||||
block: T.nilable(T.proc.params(k: T.untyped, v1: T.untyped, v2: T.untyped).returns(T.untyped)),
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:k2)), T.untyped])
|
||||
).returns(T::Hash[T.any(Hash::K, T.type_parameter(:K2)), T.untyped])
|
||||
}
|
||||
def deep_merge!(other_hash, &block); end
|
||||
end
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||
}
|
||||
def deep_transform_values(&block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:out)])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: Hash::V).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[Hash::K, T.type_parameter(:Out)])
|
||||
}
|
||||
def deep_transform_values!(&block); end
|
||||
end
|
||||
|
||||
@ -3,16 +3,16 @@
|
||||
|
||||
class Hash
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[T.type_parameter(:out), V])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||
}
|
||||
def deep_transform_keys(&block); end
|
||||
|
||||
sig {
|
||||
type_parameters(:out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:out)),
|
||||
).returns(T::Hash[T.type_parameter(:out), V])
|
||||
type_parameters(:Out).params(
|
||||
block: T.proc.params(o: K).returns(T.type_parameter(:Out)),
|
||||
).returns(T::Hash[T.type_parameter(:Out), V])
|
||||
}
|
||||
def deep_transform_keys!(&block); end
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ module Kernel
|
||||
sig { params(message: T.any(String, Exception)).void }
|
||||
def opoo(message)
|
||||
require "utils/github/actions"
|
||||
return if GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
|
||||
return if GitHub::Actions.puts_annotation_if_env_set!(:warning, message.to_s)
|
||||
|
||||
require "utils/formatter"
|
||||
|
||||
@ -106,7 +106,7 @@ module Kernel
|
||||
sig { params(message: T.any(String, Exception)).void }
|
||||
def onoe(message)
|
||||
require "utils/github/actions"
|
||||
return if GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
|
||||
return if GitHub::Actions.puts_annotation_if_env_set!(:error, message.to_s)
|
||||
|
||||
require "utils/formatter"
|
||||
|
||||
@ -204,7 +204,7 @@ module Kernel
|
||||
disable = true if disable_for_developers && Homebrew::EnvConfig.developer?
|
||||
if disable || Homebrew.raise_deprecation_exceptions?
|
||||
require "utils/github/actions"
|
||||
GitHub::Actions.puts_annotation_if_env_set(:error, message, file:, line:)
|
||||
GitHub::Actions.puts_annotation_if_env_set!(:error, message, file:, line:)
|
||||
exception = MethodDeprecatedError.new(message)
|
||||
exception.set_backtrace(backtrace)
|
||||
raise exception
|
||||
|
||||
@ -12,12 +12,12 @@ class Keg
|
||||
|
||||
elf_files.each do |file|
|
||||
file.ensure_writable do
|
||||
change_rpath(file, old_prefix, new_prefix)
|
||||
change_rpath!(file, old_prefix, new_prefix)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def change_rpath(file, old_prefix, new_prefix)
|
||||
def change_rpath!(file, old_prefix, new_prefix)
|
||||
return false if !file.elf? || !file.dynamic_elf?
|
||||
|
||||
updated = {}
|
||||
|
||||
@ -5,7 +5,7 @@ require "requirement"
|
||||
|
||||
class XcodeRequirement < Requirement
|
||||
sig { returns(T::Boolean) }
|
||||
def xcode_installed_version
|
||||
def xcode_installed_version!
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@ -38,7 +38,7 @@ module OS
|
||||
# conflict between what `uname` reports and the underlying `sysctl` flags,
|
||||
# since the `sysctl` flags don't change behaviour under Rosetta 2.
|
||||
def in_rosetta2?
|
||||
::Hardware::CPU.sysctl_bool("sysctl.proc_translated")
|
||||
::Hardware::CPU.sysctl_bool!("sysctl.proc_translated")
|
||||
end
|
||||
|
||||
def features
|
||||
@ -50,7 +50,7 @@ module OS
|
||||
end
|
||||
|
||||
def sse4?
|
||||
::Hardware::CPU.sysctl_bool("hw.optional.sse4_1")
|
||||
::Hardware::CPU.sysctl_bool!("hw.optional.sse4_1")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -68,41 +68,41 @@ module Hardware
|
||||
end
|
||||
|
||||
def aes?
|
||||
sysctl_bool("hw.optional.aes")
|
||||
sysctl_bool!("hw.optional.aes")
|
||||
end
|
||||
|
||||
def altivec?
|
||||
sysctl_bool("hw.optional.altivec")
|
||||
sysctl_bool!("hw.optional.altivec")
|
||||
end
|
||||
|
||||
def avx?
|
||||
sysctl_bool("hw.optional.avx1_0")
|
||||
sysctl_bool!("hw.optional.avx1_0")
|
||||
end
|
||||
|
||||
def avx2?
|
||||
sysctl_bool("hw.optional.avx2_0")
|
||||
sysctl_bool!("hw.optional.avx2_0")
|
||||
end
|
||||
|
||||
def sse3?
|
||||
sysctl_bool("hw.optional.sse3")
|
||||
sysctl_bool!("hw.optional.sse3")
|
||||
end
|
||||
|
||||
def ssse3?
|
||||
sysctl_bool("hw.optional.supplementalsse3")
|
||||
sysctl_bool!("hw.optional.supplementalsse3")
|
||||
end
|
||||
|
||||
def sse4_2?
|
||||
sysctl_bool("hw.optional.sse4_2")
|
||||
sysctl_bool!("hw.optional.sse4_2")
|
||||
end
|
||||
|
||||
# NOTE: This is more reliable than checking `uname`. `sysctl` returns
|
||||
# the right answer even when running in Rosetta 2.
|
||||
def physical_cpu_arm64?
|
||||
sysctl_bool("hw.optional.arm64")
|
||||
sysctl_bool!("hw.optional.arm64")
|
||||
end
|
||||
|
||||
def virtualized?
|
||||
sysctl_bool("kern.hv_vmm_present")
|
||||
sysctl_bool!("kern.hv_vmm_present")
|
||||
end
|
||||
|
||||
def arm_family
|
||||
@ -173,7 +173,7 @@ module Hardware
|
||||
end
|
||||
end
|
||||
|
||||
def sysctl_bool(key)
|
||||
def sysctl_bool!(key)
|
||||
sysctl_int(key) == 1
|
||||
end
|
||||
|
||||
|
||||
@ -306,7 +306,7 @@ class FormulaInstaller
|
||||
if force?
|
||||
opoo message
|
||||
else
|
||||
GitHub::Actions.puts_annotation_if_env_set(:error, message)
|
||||
GitHub::Actions.puts_annotation_if_env_set!(:error, message)
|
||||
raise CannotInstallFormulaError, message
|
||||
end
|
||||
end
|
||||
|
||||
@ -79,6 +79,9 @@ module Formulary
|
||||
end
|
||||
|
||||
module PathnameWriteMkpath
|
||||
# TODO: migrate away from refinements here, they don't play nicely with
|
||||
# Sorbet, when we migrate to `typed: strict`
|
||||
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||
refine Pathname do
|
||||
def write(content, offset = nil, **open_args)
|
||||
T.bind(self, Pathname)
|
||||
@ -89,6 +92,7 @@ module Formulary
|
||||
super
|
||||
end
|
||||
end
|
||||
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||
end
|
||||
|
||||
using PathnameWriteMkpath
|
||||
@ -133,7 +137,7 @@ module Formulary
|
||||
rescue NameError => e
|
||||
class_list = mod.constants
|
||||
.map { |const_name| mod.const_get(const_name) }
|
||||
.select { |const| const.is_a?(Class) }
|
||||
.grep(Class)
|
||||
new_exception = FormulaClassUnavailableError.new(name, path, class_name, class_list)
|
||||
remove_const(namespace)
|
||||
raise new_exception, "", e.backtrace
|
||||
@ -170,7 +174,7 @@ module Formulary
|
||||
end
|
||||
|
||||
sig { params(name: String, flags: T::Array[String]).returns(T.class_of(Formula)) }
|
||||
def self.load_formula_from_api(name, flags:)
|
||||
def self.load_formula_from_api!(name, flags:)
|
||||
namespace = :"FormulaNamespaceAPI#{namespace_key(name)}"
|
||||
|
||||
mod = Module.new
|
||||
@ -264,6 +268,9 @@ module Formulary
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: migrate away from this inline class here, they don't play nicely with
|
||||
# Sorbet, when we migrate to `typed: strict`
|
||||
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||
klass = Class.new(::Formula) do
|
||||
@loaded_from_api = true
|
||||
|
||||
@ -431,6 +438,7 @@ module Formulary
|
||||
Checksum.new(checksum) if checksum
|
||||
end
|
||||
end
|
||||
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||
|
||||
mod.const_set(class_name, klass)
|
||||
|
||||
@ -902,7 +910,7 @@ module Formulary
|
||||
private
|
||||
|
||||
def load_from_api(flags:)
|
||||
Formulary.load_formula_from_api(name, flags:)
|
||||
Formulary.load_formula_from_api!(name, flags:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -19,6 +19,9 @@ module Ignorable
|
||||
end
|
||||
|
||||
def self.hook_raise
|
||||
# TODO: migrate away from this inline class here, they don't play nicely with
|
||||
# Sorbet, when we migrate to `typed: strict`
|
||||
# rubocop:todo Sorbet/BlockMethodDefinition
|
||||
Object.class_eval do
|
||||
alias_method :original_raise, :raise
|
||||
|
||||
@ -37,6 +40,7 @@ module Ignorable
|
||||
|
||||
alias_method :fail, :raise
|
||||
end
|
||||
# rubocop:enable Sorbet/BlockMethodDefinition
|
||||
|
||||
return unless block_given?
|
||||
|
||||
|
||||
@ -465,9 +465,7 @@ module Homebrew
|
||||
|
||||
def collect_dependencies(formulae_installer, dependants)
|
||||
formulae_dependencies = formulae_installer.flat_map do |f|
|
||||
[f.formula, f.compute_dependencies.flatten.filter do |c|
|
||||
c.is_a? Dependency
|
||||
end.flat_map(&:to_formula)]
|
||||
[f.formula, f.compute_dependencies.flatten.grep(Dependency).flat_map(&:to_formula)]
|
||||
end.flatten.uniq
|
||||
formulae_dependencies.concat(dependants.upgradeable) if dependants&.upgradeable
|
||||
formulae_dependencies.uniq
|
||||
|
||||
@ -35,7 +35,7 @@ class Keg
|
||||
end
|
||||
|
||||
sig { params(text: String).returns(T::Boolean) }
|
||||
def replace_text(text)
|
||||
def replace_text!(text)
|
||||
replacements = @replacement_map.values.to_h
|
||||
|
||||
sorted_keys = replacements.keys.sort_by do |key|
|
||||
@ -143,7 +143,7 @@ class Keg
|
||||
files.map { path.join(_1) }.group_by { |f| f.stat.ino }.each_value do |first, *rest|
|
||||
s = first.open("rb", &:read)
|
||||
|
||||
next unless relocation.replace_text(s)
|
||||
next unless relocation.replace_text!(s)
|
||||
|
||||
changed_files += [first, *rest].map { |file| file.relative_path_from(path) }
|
||||
|
||||
|
||||
@ -323,7 +323,7 @@ module Homebrew
|
||||
end
|
||||
return unless name
|
||||
|
||||
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].count.positive?
|
||||
if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].any?
|
||||
# TODO: Handle multiple messages, only if needed in the future
|
||||
if skip_hash[:status] == "skipped"
|
||||
puts "#{Tty.red}#{name}#{Tty.reset}: skipped - #{skip_hash[:messages][0]}"
|
||||
|
||||
@ -12,7 +12,7 @@ class XcodeRequirement < Requirement
|
||||
|
||||
satisfy(build_env: false) do
|
||||
T.bind(self, XcodeRequirement)
|
||||
xcode_installed_version
|
||||
xcode_installed_version!
|
||||
end
|
||||
|
||||
sig { params(tags: T::Array[String]).void }
|
||||
@ -23,7 +23,7 @@ class XcodeRequirement < Requirement
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def xcode_installed_version
|
||||
def xcode_installed_version!
|
||||
return false unless MacOS::Xcode.installed?
|
||||
return true unless @version
|
||||
|
||||
|
||||
@ -228,13 +228,13 @@ module RuboCop
|
||||
rescue JSON::ParserError
|
||||
nil
|
||||
end
|
||||
next if list_contents.nil? || list_contents.count.zero?
|
||||
next if list_contents.nil? || list_contents.none?
|
||||
|
||||
@tap_style_exceptions[list_name] = list_contents
|
||||
end
|
||||
end
|
||||
|
||||
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.count.zero?
|
||||
return false if @tap_style_exceptions.nil? || @tap_style_exceptions.none?
|
||||
return false unless @tap_style_exceptions.key? list
|
||||
|
||||
T.must(@tap_style_exceptions[list]).include?(formula || @formula_name)
|
||||
|
||||
@ -42,7 +42,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
# Check if formula has been found.
|
||||
def self.check(targets)
|
||||
def self.check!(targets)
|
||||
raise UsageError, "Formula(e) missing, please provide a formula name or use --all" if targets.empty?
|
||||
|
||||
true
|
||||
|
||||
@ -17,7 +17,7 @@ module Homebrew
|
||||
).void
|
||||
}
|
||||
def self.run(targets, verbose:, json:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
|
||||
output = targets.map(&:to_hash)
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ module Homebrew
|
||||
|
||||
sig { params(targets: T::Array[Services::FormulaWrapper], verbose: T::Boolean).void }
|
||||
def self.run(targets, verbose:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
Services::Cli.kill(targets, verbose:)
|
||||
end
|
||||
end
|
||||
|
||||
@ -22,7 +22,7 @@ module Homebrew
|
||||
).void
|
||||
}
|
||||
def self.run(targets, custom_plist, verbose:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
|
||||
ran = []
|
||||
started = []
|
||||
|
||||
@ -17,7 +17,7 @@ module Homebrew
|
||||
).void
|
||||
}
|
||||
def self.run(targets, custom_plist, verbose:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
Services::Cli.run(targets, custom_plist, verbose:)
|
||||
end
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@ module Homebrew
|
||||
).void
|
||||
}
|
||||
def self.run(targets, custom_plist, verbose:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
Services::Cli.start(targets, custom_plist, verbose:)
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,7 +19,7 @@ module Homebrew
|
||||
).void
|
||||
}
|
||||
def self.run(targets, verbose:, no_wait:, max_wait:, keep:)
|
||||
Services::Cli.check(targets)
|
||||
Services::Cli.check!(targets)
|
||||
Services::Cli.stop(targets, verbose:, no_wait:, max_wait:, keep:)
|
||||
end
|
||||
end
|
||||
|
||||
@ -86,7 +86,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
shfmt_result = files.present? && shell_files.empty?
|
||||
shfmt_result ||= run_shfmt(shell_files, fix:)
|
||||
shfmt_result ||= run_shfmt!(shell_files, fix:)
|
||||
|
||||
actionlint_files = github_workflow_files if files.blank? && actionlint_files.blank?
|
||||
has_actionlint_workflow = actionlint_files.any? do |path|
|
||||
@ -94,7 +94,7 @@ module Homebrew
|
||||
end
|
||||
odebug "actionlint workflow detected. Skipping actionlint checks." if has_actionlint_workflow
|
||||
actionlint_result = files.present? && (has_actionlint_workflow || actionlint_files.empty?)
|
||||
actionlint_result ||= run_actionlint(actionlint_files)
|
||||
actionlint_result ||= run_actionlint!(actionlint_files)
|
||||
|
||||
if output_type == :json
|
||||
Offenses.new(rubocop_result + shellcheck_result)
|
||||
@ -176,7 +176,7 @@ module Homebrew
|
||||
|
||||
# Don't show the default formatter's progress dots
|
||||
# on CI or if only checking a single file.
|
||||
args << "--format" << "clang" if ENV["CI"] || files.count { |f| !f.directory? } == 1
|
||||
args << "--format" << "clang" if ENV["CI"] || files.one? { |f| !f.directory? }
|
||||
|
||||
args << "--color" if Tty.color?
|
||||
|
||||
@ -264,7 +264,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def self.run_shfmt(files, fix: false)
|
||||
def self.run_shfmt!(files, fix: false)
|
||||
files = shell_scripts if files.blank?
|
||||
# Do not format completions and Dockerfile
|
||||
files.delete(HOMEBREW_REPOSITORY/"completions/bash/brew")
|
||||
@ -277,7 +277,7 @@ module Homebrew
|
||||
$CHILD_STATUS.success?
|
||||
end
|
||||
|
||||
def self.run_actionlint(files)
|
||||
def self.run_actionlint!(files)
|
||||
files = github_workflow_files if files.blank?
|
||||
# the ignore is to avoid false positives in e.g. actions, homebrew-test-bot
|
||||
system actionlint, "-shellcheck", shellcheck,
|
||||
|
||||
@ -55,7 +55,7 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
|
||||
it "skips" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(described_class.preinstall("google-chrome")).to be(false)
|
||||
expect(described_class.preinstall!("google-chrome")).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -69,8 +69,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "google-chrome", verbose: false)
|
||||
.and_return(true)
|
||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
||||
expect(described_class.install("google-chrome")).to be(true)
|
||||
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||
expect(described_class.install!("google-chrome")).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -85,8 +85,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--cask", "opera", verbose: false)
|
||||
.and_return(true)
|
||||
expect(described_class.preinstall("opera", greedy: true)).to be(true)
|
||||
expect(described_class.install("opera", greedy: true)).to be(true)
|
||||
expect(described_class.preinstall!("opera", greedy: true)).to be(true)
|
||||
expect(described_class.install!("opera", greedy: true)).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -99,8 +99,8 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
||||
verbose: false)
|
||||
.and_return(true)
|
||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
||||
expect(described_class.install("google-chrome")).to be(true)
|
||||
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||
expect(described_class.install!("google-chrome")).to be(true)
|
||||
end
|
||||
|
||||
it "installs cask with arguments" do
|
||||
@ -109,16 +109,16 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
verbose: false)
|
||||
.and_return(true),
|
||||
)
|
||||
expect(described_class.preinstall("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||
expect(described_class.install("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||
expect(described_class.preinstall!("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||
expect(described_class.install!("firefox", args: { appdir: "/Applications" })).to be(true)
|
||||
end
|
||||
|
||||
it "reports a failure" do
|
||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "google-chrome", "--adopt",
|
||||
verbose: false)
|
||||
.and_return(false)
|
||||
expect(described_class.preinstall("google-chrome")).to be(true)
|
||||
expect(described_class.install("google-chrome")).to be(false)
|
||||
expect(described_class.preinstall!("google-chrome")).to be(true)
|
||||
expect(described_class.install!("google-chrome")).to be(false)
|
||||
end
|
||||
|
||||
context "with boolean arguments" do
|
||||
@ -126,15 +126,15 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--force",
|
||||
verbose: false)
|
||||
.and_return(true)
|
||||
expect(described_class.preinstall("iterm", args: { force: true })).to be(true)
|
||||
expect(described_class.install("iterm", args: { force: true })).to be(true)
|
||||
expect(described_class.preinstall!("iterm", args: { force: true })).to be(true)
|
||||
expect(described_class.install!("iterm", args: { force: true })).to be(true)
|
||||
end
|
||||
|
||||
it "does not include a flag if false" do
|
||||
expect(Homebrew::Bundle).to receive(:brew).with("install", "--cask", "iterm", "--adopt", verbose: false)
|
||||
.and_return(true)
|
||||
expect(described_class.preinstall("iterm", args: { force: false })).to be(true)
|
||||
expect(described_class.install("iterm", args: { force: false })).to be(true)
|
||||
expect(described_class.preinstall!("iterm", args: { force: false })).to be(true)
|
||||
expect(described_class.install!("iterm", args: { force: false })).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -150,14 +150,14 @@ RSpec.describe Homebrew::Bundle::CaskInstaller do
|
||||
|
||||
it "runs the postinstall command" do
|
||||
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
||||
expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true)
|
||||
expect(described_class.install("google-chrome", postinstall: "custom command")).to be(true)
|
||||
expect(described_class.preinstall!("google-chrome", postinstall: "custom command")).to be(true)
|
||||
expect(described_class.install!("google-chrome", postinstall: "custom command")).to be(true)
|
||||
end
|
||||
|
||||
it "reports a failure when postinstall fails" do
|
||||
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
||||
expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true)
|
||||
expect(described_class.install("google-chrome", postinstall: "custom command")).to be(false)
|
||||
expect(described_class.preinstall!("google-chrome", postinstall: "custom command")).to be(true)
|
||||
expect(described_class.install!("google-chrome", postinstall: "custom command")).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,28 +28,28 @@ RSpec.describe Homebrew::Bundle::Commands::Install do
|
||||
end
|
||||
|
||||
it "does not raise an error" do
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall).and_return(false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall!).and_return(false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall!).and_return(false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||
expect { described_class.run }.not_to raise_error
|
||||
end
|
||||
|
||||
it "#dsl returns a valid DSL" do
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall).and_return(false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive(:preinstall!).and_return(false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive(:preinstall!).and_return(false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||
described_class.run
|
||||
expect(described_class.dsl.entries.first.name).to eql("phinze/cask")
|
||||
end
|
||||
|
||||
it "does not raise an error when skippable" do
|
||||
expect(Homebrew::Bundle::FormulaInstaller).not_to receive(:install)
|
||||
expect(Homebrew::Bundle::FormulaInstaller).not_to receive(:install!)
|
||||
|
||||
allow(Homebrew::Bundle::Skipper).to receive(:skip?).and_return(true)
|
||||
allow_any_instance_of(Pathname).to receive(:read)
|
||||
@ -58,22 +58,22 @@ RSpec.describe Homebrew::Bundle::Commands::Install do
|
||||
end
|
||||
|
||||
it "exits on failures" do
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||
|
||||
expect { described_class.run }.to raise_error(SystemExit)
|
||||
end
|
||||
|
||||
it "skips installs from failed taps" do
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive(:preinstall).and_return(false)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall: true, install: false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: true)
|
||||
allow(Homebrew::Bundle::CaskInstaller).to receive(:preinstall!).and_return(false)
|
||||
allow(Homebrew::Bundle::TapInstaller).to receive_messages(preinstall!: true, install!: false)
|
||||
allow(Homebrew::Bundle::FormulaInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::MacAppStoreInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow(Homebrew::Bundle::VscodeExtensionInstaller).to receive_messages(preinstall!: true, install!: true)
|
||||
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
|
||||
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
|
||||
@ -37,15 +37,15 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
context "with a successful installation" do
|
||||
it "start service" do
|
||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
||||
described_class.preinstall(formula_name, start_service: true)
|
||||
described_class.install(formula_name, start_service: true)
|
||||
described_class.preinstall!(formula_name, start_service: true)
|
||||
described_class.install!(formula_name, start_service: true)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a skipped installation" do
|
||||
it "start service" do
|
||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:start)
|
||||
described_class.install(formula_name, preinstall: false, start_service: true)
|
||||
described_class.install!(formula_name, preinstall: false, start_service: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -59,8 +59,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "start service" do
|
||||
expect(Homebrew::Bundle::BrewServices).to \
|
||||
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, start_service: true)
|
||||
described_class.install(formula_name, start_service: true)
|
||||
described_class.preinstall!(formula_name, start_service: true)
|
||||
described_class.install!(formula_name, start_service: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -68,7 +68,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "start service" do
|
||||
expect(Homebrew::Bundle::BrewServices).to \
|
||||
receive(:start).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||
described_class.install(formula_name, preinstall: false, start_service: true)
|
||||
described_class.install!(formula_name, preinstall: false, start_service: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -84,8 +84,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "restart service" do
|
||||
expect(Homebrew::Bundle::BrewServices).to \
|
||||
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, restart_service: :always)
|
||||
described_class.install(formula_name, restart_service: :always)
|
||||
described_class.preinstall!(formula_name, restart_service: :always)
|
||||
described_class.install!(formula_name, restart_service: :always)
|
||||
end
|
||||
end
|
||||
|
||||
@ -93,7 +93,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "restart service" do
|
||||
expect(Homebrew::Bundle::BrewServices).to \
|
||||
receive(:restart).with(formula_name, file: nil, verbose: false).and_return(true)
|
||||
described_class.install(formula_name, preinstall: false, restart_service: :always)
|
||||
described_class.install!(formula_name, preinstall: false, restart_service: :always)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -107,8 +107,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: true)
|
||||
described_class.install(formula_name, link: true)
|
||||
described_class.preinstall!(formula_name, link: true)
|
||||
described_class.install!(formula_name, link: true)
|
||||
end
|
||||
|
||||
it "force-links keg-only formula" do
|
||||
@ -116,8 +116,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
allow_any_instance_of(described_class).to receive(:keg_only?).and_return(true)
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--force", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: true)
|
||||
described_class.install(formula_name, link: true)
|
||||
described_class.preinstall!(formula_name, link: true)
|
||||
described_class.install!(formula_name, link: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -130,8 +130,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(false)
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "--overwrite", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: :overwrite)
|
||||
described_class.install(formula_name, link: :overwrite)
|
||||
described_class.preinstall!(formula_name, link: :overwrite)
|
||||
described_class.install!(formula_name, link: :overwrite)
|
||||
end
|
||||
end
|
||||
|
||||
@ -144,8 +144,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
allow_any_instance_of(described_class).to receive(:linked?).and_return(true)
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: false)
|
||||
described_class.install(formula_name, link: false)
|
||||
described_class.preinstall!(formula_name, link: false)
|
||||
described_class.install!(formula_name, link: false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -159,8 +159,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "links formula" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "link", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: nil)
|
||||
described_class.install(formula_name, link: nil)
|
||||
described_class.preinstall!(formula_name, link: nil)
|
||||
described_class.install!(formula_name, link: nil)
|
||||
end
|
||||
end
|
||||
|
||||
@ -174,9 +174,9 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "unlinks formula" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "unlink", "mysql",
|
||||
verbose: false).and_return(true)
|
||||
described_class.preinstall(formula_name, link: nil)
|
||||
described_class.preinstall!(formula_name, link: nil)
|
||||
|
||||
described_class.install(formula_name, link: nil)
|
||||
described_class.install!(formula_name, link: nil)
|
||||
end
|
||||
end
|
||||
|
||||
@ -188,8 +188,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
conflicts_with: ["mysql55"],
|
||||
)
|
||||
allow(described_class).to receive(:formula_installed?).and_return(true)
|
||||
allow_any_instance_of(described_class).to receive(:install!).and_return(true)
|
||||
allow_any_instance_of(described_class).to receive(:upgrade!).and_return(true)
|
||||
allow_any_instance_of(described_class).to receive(:install_formula!).and_return(true)
|
||||
allow_any_instance_of(described_class).to receive(:upgrade_formula!).and_return(true)
|
||||
end
|
||||
|
||||
it "unlinks conflicts and stops their services" do
|
||||
@ -203,8 +203,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
||||
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
||||
verbose:).and_return(true)
|
||||
described_class.preinstall(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||
described_class.install(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||
described_class.preinstall!(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||
described_class.install!(formula_name, restart_service: :always, conflicts_with: ["mysql56"])
|
||||
end
|
||||
|
||||
it "prints a message" do
|
||||
@ -219,8 +219,10 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
expect(Homebrew::Bundle::BrewServices).to receive(:stop).with("mysql56", verbose:).and_return(true)
|
||||
expect(Homebrew::Bundle::BrewServices).to receive(:restart).with(formula_name, file: nil,
|
||||
verbose:).and_return(true)
|
||||
described_class.preinstall(formula_name, restart_service: :always, conflicts_with: ["mysql56"], verbose: true)
|
||||
described_class.install(formula_name, restart_service: :always, conflicts_with: ["mysql56"], verbose: true)
|
||||
described_class.preinstall!(formula_name, restart_service: :always, conflicts_with: ["mysql56"],
|
||||
verbose: true)
|
||||
described_class.install!(formula_name, restart_service: :always, conflicts_with: ["mysql56"],
|
||||
verbose: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -237,14 +239,14 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
|
||||
it "runs the postinstall command" do
|
||||
expect(Kernel).to receive(:system).with("custom command").and_return(true)
|
||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
||||
described_class.install(formula_name, postinstall: "custom command")
|
||||
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||
described_class.install!(formula_name, postinstall: "custom command")
|
||||
end
|
||||
|
||||
it "reports a failure" do
|
||||
expect(Kernel).to receive(:system).with("custom command").and_return(false)
|
||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
||||
expect(described_class.install(formula_name, postinstall: "custom command")).to be(false)
|
||||
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||
expect(described_class.install!(formula_name, postinstall: "custom command")).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -255,8 +257,8 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
|
||||
it "does not run the postinstall command" do
|
||||
expect(Kernel).not_to receive(:system)
|
||||
described_class.preinstall(formula_name, postinstall: "custom command")
|
||||
described_class.install(formula_name, postinstall: "custom command")
|
||||
described_class.preinstall!(formula_name, postinstall: "custom command")
|
||||
described_class.install!(formula_name, postinstall: "custom command")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -281,16 +283,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
|
||||
it "writes the version to the file" do
|
||||
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
||||
described_class.preinstall(formula_name, version_file:)
|
||||
described_class.install(formula_name, version_file:)
|
||||
described_class.preinstall!(formula_name, version_file:)
|
||||
described_class.install!(formula_name, version_file:)
|
||||
end
|
||||
end
|
||||
|
||||
context "when using the latest formula" do
|
||||
it "writes the version to the file" do
|
||||
expect(File).to receive(:write).with(version_file, "#{version}\n")
|
||||
described_class.preinstall(formula_name, version_file:)
|
||||
described_class.install(formula_name, version_file:)
|
||||
described_class.preinstall!(formula_name, version_file:)
|
||||
described_class.install!(formula_name, version_file:)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -304,7 +306,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
|
||||
it "did not call restart service" do
|
||||
expect(Homebrew::Bundle::BrewServices).not_to receive(:restart)
|
||||
described_class.preinstall(formula_name, restart_service: true)
|
||||
described_class.preinstall!(formula_name, restart_service: true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -386,16 +388,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
expect(Homebrew::Bundle).to receive(:system)
|
||||
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
||||
.and_return(true)
|
||||
expect(installer.preinstall).to be(true)
|
||||
expect(installer.install).to be(true)
|
||||
expect(installer.preinstall!).to be(true)
|
||||
expect(installer.install!).to be(true)
|
||||
end
|
||||
|
||||
it "reports a failure" do
|
||||
expect(Homebrew::Bundle).to receive(:system)
|
||||
.with(HOMEBREW_BREW_FILE, "install", "--formula", formula_name, "--with-option", verbose: false)
|
||||
.and_return(false)
|
||||
expect(installer.preinstall).to be(true)
|
||||
expect(installer.install).to be(false)
|
||||
expect(installer.preinstall!).to be(true)
|
||||
expect(installer.install!).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -416,16 +418,16 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||
.and_return(true)
|
||||
expect(installer.preinstall).to be(true)
|
||||
expect(installer.install).to be(true)
|
||||
expect(installer.preinstall!).to be(true)
|
||||
expect(installer.install!).to be(true)
|
||||
end
|
||||
|
||||
it "reports a failure" do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||
.and_return(false)
|
||||
expect(installer.preinstall).to be(true)
|
||||
expect(installer.install).to be(false)
|
||||
expect(installer.preinstall!).to be(true)
|
||||
expect(installer.install!).to be(false)
|
||||
end
|
||||
|
||||
context "when formula pinned" do
|
||||
@ -436,7 +438,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
it "does not upgrade formula" do
|
||||
expect(Homebrew::Bundle).not_to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "upgrade", "--formula", formula_name, verbose: false)
|
||||
expect(installer.preinstall).to be(false)
|
||||
expect(installer.preinstall!).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -447,7 +449,7 @@ RSpec.describe Homebrew::Bundle::FormulaInstaller do
|
||||
|
||||
it "does not upgrade formula" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(installer.preinstall).to be(false)
|
||||
expect(installer.preinstall!).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
||||
it "tries to install mas" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "mas",
|
||||
verbose: false).and_return(true)
|
||||
expect { described_class.preinstall("foo", 123) }.to raise_error(RuntimeError)
|
||||
expect { described_class.preinstall!("foo", 123) }.to raise_error(RuntimeError)
|
||||
end
|
||||
|
||||
describe ".outdated_app_ids" do
|
||||
@ -62,7 +62,7 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
||||
|
||||
it "skips" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(described_class.preinstall("foo", 123)).to be(false)
|
||||
expect(described_class.preinstall!("foo", 123)).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -73,8 +73,8 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
||||
|
||||
it "upgrades" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with("mas", "upgrade", "123", verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("foo", 123)).to be(true)
|
||||
expect(described_class.install("foo", 123)).to be(true)
|
||||
expect(described_class.preinstall!("foo", 123)).to be(true)
|
||||
expect(described_class.install!("foo", 123)).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -85,8 +85,8 @@ RSpec.describe Homebrew::Bundle::MacAppStoreInstaller do
|
||||
|
||||
it "installs app" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with("mas", "install", "123", verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("foo", 123)).to be(true)
|
||||
expect(described_class.install("foo", 123)).to be(true)
|
||||
expect(described_class.preinstall!("foo", 123)).to be(true)
|
||||
expect(described_class.install!("foo", 123)).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -22,7 +22,7 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
||||
|
||||
it "skips" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(described_class.preinstall("homebrew/cask")).to be(false)
|
||||
expect(described_class.preinstall!("homebrew/cask")).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,8 +34,8 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
||||
it "taps" do
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask",
|
||||
verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("homebrew/cask")).to be(true)
|
||||
expect(described_class.install("homebrew/cask")).to be(true)
|
||||
expect(described_class.preinstall!("homebrew/cask")).to be(true)
|
||||
expect(described_class.install!("homebrew/cask")).to be(true)
|
||||
end
|
||||
|
||||
context "with clone target" do
|
||||
@ -43,16 +43,16 @@ RSpec.describe Homebrew::Bundle::TapInstaller do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
||||
verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
expect(described_class.install("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
expect(described_class.preinstall!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
expect(described_class.install!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
end
|
||||
|
||||
it "fails" do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "tap", "homebrew/cask", "clone_target_path",
|
||||
verbose: false).and_return(false)
|
||||
expect(described_class.preinstall("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
expect(described_class.install("homebrew/cask", clone_target: "clone_target_path")).to be(false)
|
||||
expect(described_class.preinstall!("homebrew/cask", clone_target: "clone_target_path")).to be(true)
|
||||
expect(described_class.install!("homebrew/cask", clone_target: "clone_target_path")).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(HOMEBREW_BREW_FILE, "install", "--cask", "visual-studio-code", verbose: false)
|
||||
.and_return(true)
|
||||
expect { described_class.preinstall("foo") }.to raise_error(RuntimeError)
|
||||
expect { described_class.preinstall!("foo") }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
||||
@ -31,12 +31,12 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
||||
|
||||
it "skips" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(described_class.preinstall("foo")).to be(false)
|
||||
expect(described_class.preinstall!("foo")).to be(false)
|
||||
end
|
||||
|
||||
it "skips ignoring case" do
|
||||
expect(Homebrew::Bundle).not_to receive(:system)
|
||||
expect(described_class.preinstall("Foo")).to be(false)
|
||||
expect(described_class.preinstall!("Foo")).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -48,8 +48,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
||||
it "installs extension" do
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("foo")).to be(true)
|
||||
expect(described_class.install("foo")).to be(true)
|
||||
expect(described_class.preinstall!("foo")).to be(true)
|
||||
expect(described_class.install!("foo")).to be(true)
|
||||
end
|
||||
|
||||
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns true" do
|
||||
@ -59,8 +59,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
||||
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("foo")).to be(true)
|
||||
expect(described_class.install("foo")).to be(true)
|
||||
expect(described_class.preinstall!("foo")).to be(true)
|
||||
expect(described_class.install!("foo")).to be(true)
|
||||
end
|
||||
|
||||
it "installs extension when euid != uid and Process::UID.re_exchangeable? returns false" do
|
||||
@ -70,8 +70,8 @@ RSpec.describe Homebrew::Bundle::VscodeExtensionInstaller do
|
||||
|
||||
expect(Homebrew::Bundle).to \
|
||||
receive(:system).with(Pathname("code"), "--install-extension", "foo", verbose: false).and_return(true)
|
||||
expect(described_class.preinstall("foo")).to be(true)
|
||||
expect(described_class.install("foo")).to be(true)
|
||||
expect(described_class.preinstall!("foo")).to be(true)
|
||||
expect(described_class.install!("foo")).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ RSpec.describe Homebrew::Bundle::WhalebrewInstaller do
|
||||
expect(Homebrew::Bundle).to receive(:system).with(HOMEBREW_BREW_FILE, "install", "--formula", "whalebrew",
|
||||
verbose: false)
|
||||
.and_return(true)
|
||||
expect { described_class.preinstall("whalebrew/wget") }.to raise_error(RuntimeError)
|
||||
expect { described_class.preinstall!("whalebrew/wget") }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
||||
@ -61,7 +61,7 @@ RSpec.describe Homebrew::Bundle::WhalebrewInstaller do
|
||||
end
|
||||
|
||||
it "skips" do
|
||||
expect(described_class.preinstall("whalebrew/wget")).to be(false)
|
||||
expect(described_class.preinstall!("whalebrew/wget")).to be(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -59,7 +59,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(renamed_app_new_path).not_to be_a_directory
|
||||
expect(renamed_app.installed_version).to eq "1.0.0"
|
||||
|
||||
described_class.upgrade_casks(dry_run: true, args:)
|
||||
described_class.upgrade_casks!(dry_run: true, args:)
|
||||
|
||||
expect(local_caffeine).to be_installed
|
||||
expect(local_caffeine_path).to be_a_directory
|
||||
@ -86,7 +86,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(local_transmission_path).to be_a_directory
|
||||
expect(local_transmission.installed_version).to eq "2.60"
|
||||
|
||||
described_class.upgrade_casks(local_caffeine, dry_run: true, args:)
|
||||
described_class.upgrade_casks!(local_caffeine, dry_run: true, args:)
|
||||
|
||||
expect(local_caffeine).to be_installed
|
||||
expect(local_caffeine_path).to be_a_directory
|
||||
@ -113,7 +113,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(renamed_app_new_path).not_to be_a_directory
|
||||
expect(renamed_app.installed_version).to eq "1.0.0"
|
||||
|
||||
described_class.upgrade_casks(local_caffeine, auto_updates, dry_run: true, args:)
|
||||
described_class.upgrade_casks!(local_caffeine, auto_updates, dry_run: true, args:)
|
||||
|
||||
expect(local_caffeine).to be_installed
|
||||
expect(local_caffeine_path).to be_a_directory
|
||||
@ -156,7 +156,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
version_latest.download_sha_path.write("fake download sha")
|
||||
expect(version_latest.outdated_download_sha?).to be(true)
|
||||
|
||||
described_class.upgrade_casks(greedy: true, dry_run: true, args:)
|
||||
described_class.upgrade_casks!(greedy: true, dry_run: true, args:)
|
||||
|
||||
expect(local_caffeine).to be_installed
|
||||
expect(local_caffeine_path).to be_a_directory
|
||||
@ -186,7 +186,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(auto_updates_path).to be_a_directory
|
||||
expect(auto_updates.installed_version).to eq "2.57"
|
||||
|
||||
described_class.upgrade_casks(auto_updates, dry_run: true, greedy: true, args:)
|
||||
described_class.upgrade_casks!(auto_updates, dry_run: true, greedy: true, args:)
|
||||
|
||||
expect(auto_updates).to be_installed
|
||||
expect(auto_updates_path).to be_a_directory
|
||||
@ -203,7 +203,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
version_latest.download_sha_path.write("fake download sha")
|
||||
expect(version_latest.outdated_download_sha?).to be(true)
|
||||
|
||||
described_class.upgrade_casks(version_latest, dry_run: true, greedy: true, args:)
|
||||
described_class.upgrade_casks!(version_latest, dry_run: true, greedy: true, args:)
|
||||
|
||||
expect(version_latest).to be_installed
|
||||
expect(version_latest_paths).to all be_a_directory
|
||||
@ -234,7 +234,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(will_fail_if_upgraded.installed_version).to eq "1.2.2"
|
||||
|
||||
expect do
|
||||
described_class.upgrade_casks(will_fail_if_upgraded, args:)
|
||||
described_class.upgrade_casks!(will_fail_if_upgraded, args:)
|
||||
end.to raise_error(Cask::CaskError).and output(output_reverted).to_stderr
|
||||
|
||||
expect(will_fail_if_upgraded).to be_installed
|
||||
@ -252,7 +252,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(bad_checksum.installed_version).to eq "1.2.2"
|
||||
|
||||
expect do
|
||||
described_class.upgrade_casks(bad_checksum, args:)
|
||||
described_class.upgrade_casks!(bad_checksum, args:)
|
||||
end.to raise_error(ChecksumMismatchError).and(not_to_output(output_reverted).to_stderr)
|
||||
|
||||
expect(bad_checksum).to be_installed
|
||||
@ -291,7 +291,7 @@ RSpec.describe Cask::Upgrade, :cask do
|
||||
expect(bad_checksum_2.installed_version).to eq "1.2.2"
|
||||
|
||||
expect do
|
||||
described_class.upgrade_casks(args:)
|
||||
described_class.upgrade_casks!(args:)
|
||||
end.to raise_error(Cask::MultipleCaskErrors)
|
||||
|
||||
expect(bad_checksum).to be_installed
|
||||
|
||||
@ -5,9 +5,12 @@ require "extend/blank"
|
||||
RSpec.describe Object do
|
||||
let(:empty_true) do
|
||||
Class.new(described_class) do
|
||||
# This API is intentionally non-ideal for testing.
|
||||
# rubocop:disable Naming/PredicateMethod
|
||||
def empty?
|
||||
0
|
||||
end
|
||||
# rubocop:enable Naming/PredicateMethod
|
||||
end
|
||||
end
|
||||
let(:empty_false) do
|
||||
|
||||
@ -32,11 +32,11 @@ RSpec.describe Keg::Relocation do
|
||||
expect(relocation.replacement_pair_for(:library_placeholder)).to eq [library_placeholder, library]
|
||||
end
|
||||
|
||||
specify "#replace_text" do
|
||||
specify "#replace_text!" do
|
||||
relocation = setup_relocation
|
||||
|
||||
text = +"foo"
|
||||
relocation.replace_text(text)
|
||||
relocation.replace_text!(text)
|
||||
expect(text).to eq "foo"
|
||||
|
||||
text = <<~TEXT
|
||||
@ -47,7 +47,7 @@ RSpec.describe Keg::Relocation do
|
||||
#{repository_placeholder}/foo
|
||||
foo#{library_placeholder}/bar
|
||||
TEXT
|
||||
relocation.replace_text(text)
|
||||
relocation.replace_text!(text)
|
||||
expect(text).to eq <<~REPLACED
|
||||
#{prefix_placeholder}/foo
|
||||
#{cellar_placeholder}/foo
|
||||
|
||||
@ -42,16 +42,16 @@ RSpec.describe Homebrew::Services::Cli do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#check" do
|
||||
describe "#check!" do
|
||||
it "checks the input does not exist" do
|
||||
expect do
|
||||
services_cli.check([])
|
||||
services_cli.check!([])
|
||||
end.to raise_error(UsageError, "Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
||||
end
|
||||
|
||||
it "checks the input exists" do
|
||||
expect do
|
||||
services_cli.check("hello")
|
||||
services_cli.check!("hello")
|
||||
end.not_to raise_error(UsageError,
|
||||
"Invalid usage: Formula(e) missing, please provide a formula name or use --all")
|
||||
end
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "tapioca/dsl"
|
||||
require "sorbet/tapioca/compilers/args"
|
||||
|
||||
RSpec.describe Tapioca::Compilers::Args do
|
||||
let(:compiler) { described_class.new(Tapioca::Dsl::Pipeline.new(requested_constants: []), RBI::Tree.new, Homebrew) }
|
||||
let(:list_parser) do
|
||||
require "cmd/list"
|
||||
Homebrew::Cmd::List.parser
|
||||
end
|
||||
|
||||
# Good testing candidate because it has multiple for each of `switch`, `flag` and `comma_array` args:
|
||||
let(:update_python_resources_parser) do
|
||||
require "dev-cmd/update-python-resources"
|
||||
Homebrew::DevCmd::UpdatePythonResources.parser
|
||||
end
|
||||
|
||||
describe "#args_table" do
|
||||
it "returns a mapping of list args to default values" do
|
||||
expect(compiler.args_table(list_parser)).to contain_exactly(
|
||||
:"1?", :built_from_source?, :cask?, :casks?, :d?, :debug?, :formula?, :formulae?, :full_name?, :h?, :help?,
|
||||
:installed_as_dependency?, :installed_on_request?, :l?, :multiple?, :pinned?, :poured_from_bottle?, :q?,
|
||||
:quiet?, :r?, :t?, :v?, :verbose?, :versions?
|
||||
)
|
||||
end
|
||||
|
||||
it "returns a mapping of update-python-resources args to default values" do
|
||||
expect(compiler.args_table(update_python_resources_parser)).to contain_exactly(
|
||||
:d?, :debug?, :exclude_packages, :extra_packages, :h?, :help?, :ignore_errors?, :ignore_non_pypi_packages?,
|
||||
:install_dependencies?, :p?, :package_name, :print_only?, :q?, :quiet?, :s?, :silent?, :v?, :verbose?,
|
||||
:version
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#comma_arrays" do
|
||||
it "returns an empty list when there are no comma_array args" do
|
||||
expect(compiler.comma_arrays(list_parser)).to eq([])
|
||||
end
|
||||
|
||||
it "returns the comma_array args when they exist" do
|
||||
expect(compiler.comma_arrays(update_python_resources_parser)).to eq([:extra_packages, :exclude_packages])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#get_return_type" do
|
||||
let(:comma_arrays) { compiler.comma_arrays(update_python_resources_parser) }
|
||||
|
||||
it "returns the correct type for switches" do
|
||||
expect(compiler.get_return_type(:silent?, comma_arrays)).to eq("T::Boolean")
|
||||
end
|
||||
|
||||
it "returns the correct type for flags" do
|
||||
expect(compiler.get_return_type(:package_name, comma_arrays)).to eq("T.nilable(String)")
|
||||
end
|
||||
|
||||
it "returns the correct type for comma_arrays" do
|
||||
expect(compiler.get_return_type(:extra_packages, comma_arrays)).to eq("T.nilable(T::Array[String])")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -48,7 +48,7 @@ module Homebrew
|
||||
if rack.directory?
|
||||
versions = rack.subdirs.map(&:basename)
|
||||
puts <<~EOS
|
||||
#{keg.name} #{versions.to_sentence} #{(versions.count == 1) ? "is" : "are"} still installed.
|
||||
#{keg.name} #{versions.to_sentence} #{versions.one? ? "is" : "are"} still installed.
|
||||
To remove all versions, run:
|
||||
brew uninstall --force #{keg.name}
|
||||
EOS
|
||||
@ -108,13 +108,13 @@ module Homebrew
|
||||
return if ignore_dependencies
|
||||
|
||||
all_kegs = kegs_by_rack.values.flatten(1)
|
||||
check_for_dependents(all_kegs, casks:, named_args:)
|
||||
check_for_dependents!(all_kegs, casks:, named_args:)
|
||||
rescue MethodDeprecatedError
|
||||
# Silently ignore deprecations when uninstalling.
|
||||
nil
|
||||
end
|
||||
|
||||
def self.check_for_dependents(kegs, casks: [], named_args: [])
|
||||
def self.check_for_dependents!(kegs, casks: [], named_args: [])
|
||||
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))
|
||||
|
||||
DependentsMessage.new(*result, named_args:).output
|
||||
@ -133,7 +133,7 @@ module Homebrew
|
||||
def output
|
||||
ofail <<~EOS
|
||||
Refusing to uninstall #{reqs.to_sentence}
|
||||
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
||||
because #{reqs.one? ? "it" : "they"} #{are_required_by_deps}.
|
||||
You can override this and force removal with:
|
||||
#{sample_command}
|
||||
EOS
|
||||
@ -146,8 +146,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
def are_required_by_deps
|
||||
"#{(reqs.count == 1) ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{(deps.count == 1) ? "is" : "are"} currently installed"
|
||||
"#{reqs.one? ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||
"which #{deps.one? ? "is" : "are"} currently installed"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -72,17 +72,17 @@ module Homebrew
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_app_cask?
|
||||
apps.count == 1
|
||||
apps.one?
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_qlplugin_cask?
|
||||
qlplugins.count == 1
|
||||
qlplugins.one?
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def single_pkg_cask?
|
||||
pkgs.count == 1
|
||||
pkgs.one?
|
||||
end
|
||||
|
||||
# Filter paths to `Info.plist` files so that ones belonging
|
||||
@ -222,14 +222,14 @@ module Homebrew
|
||||
unique_info_plist_versions =
|
||||
top_level_info_plist_paths.filter_map { |i| BundleVersion.from_info_plist(i)&.nice_version }
|
||||
.uniq
|
||||
return unique_info_plist_versions.first if unique_info_plist_versions.count == 1
|
||||
return unique_info_plist_versions.first if unique_info_plist_versions.one?
|
||||
|
||||
package_info_path = extract_dir/"PackageInfo"
|
||||
if package_info_path.exist?
|
||||
if (version = BundleVersion.from_package_info(package_info_path))
|
||||
return version.nice_version
|
||||
end
|
||||
elsif packages.count == 1
|
||||
elsif packages.one?
|
||||
onoe "#{pkg_path.basename} does not contain a `PackageInfo` file."
|
||||
end
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@ require "context"
|
||||
module Homebrew
|
||||
extend Context
|
||||
|
||||
# Need to keep this naming as-is for backwards compatibility.
|
||||
# rubocop:disable Naming/PredicateMethod
|
||||
def self._system(cmd, *args, **options)
|
||||
pid = fork do
|
||||
yield if block_given?
|
||||
@ -20,6 +22,7 @@ module Homebrew
|
||||
Process.wait(T.must(pid))
|
||||
$CHILD_STATUS.success?
|
||||
end
|
||||
# rubocop:enable Naming/PredicateMethod
|
||||
|
||||
def self.system(cmd, *args, **options)
|
||||
if verbose?
|
||||
|
||||
@ -445,7 +445,7 @@ module Utils
|
||||
format "%#{index_width}s", index_header
|
||||
formatted_name_with_options_header =
|
||||
format "%-#{name_with_options_width}s",
|
||||
name_with_options_header[0..name_with_options_width-1]
|
||||
name_with_options_header[0..(name_with_options_width-1)]
|
||||
formatted_count_header =
|
||||
format "%#{count_width}s", count_header
|
||||
formatted_percent_header =
|
||||
@ -464,7 +464,7 @@ module Utils
|
||||
formatted_index = format "%-#{index_width}s", formatted_index
|
||||
formatted_name_with_options =
|
||||
format "%-#{name_with_options_width}s",
|
||||
name_with_options[0..name_with_options_width-1]
|
||||
name_with_options[0..(name_with_options_width-1)]
|
||||
formatted_count = format "%#{count_width}s", format_count(count)
|
||||
formatted_percent = if total_count.zero?
|
||||
format "%#{percent_width}s", format_percent(0)
|
||||
|
||||
@ -45,7 +45,7 @@ module GitHub
|
||||
line: T.nilable(Integer)
|
||||
).returns(T::Boolean)
|
||||
}
|
||||
def self.puts_annotation_if_env_set(type, message, file: nil, line: nil)
|
||||
def self.puts_annotation_if_env_set!(type, message, file: nil, line: nil)
|
||||
# Don't print annotations during tests, too messy to handle these.
|
||||
return false if ENV.fetch("HOMEBREW_TESTS", false)
|
||||
return false unless env_set?
|
||||
|
||||
@ -776,6 +776,6 @@ class Version
|
||||
|
||||
sig { params(first: Integer, second: Integer).returns(Integer) }
|
||||
def max(first, second)
|
||||
(first > second) ? first : second
|
||||
[first, second].max
|
||||
end
|
||||
end
|
||||
|
||||
@ -37,6 +37,8 @@ Style/TopLevelMethodDefinition:
|
||||
Lint/NonAtomicFileOperation:
|
||||
Enabled: false
|
||||
|
||||
# The markdown linter config files don't need to be typed strict.
|
||||
# We're not using Sorbet for the documentation.
|
||||
Sorbet/StrictSigil:
|
||||
Enabled: false
|
||||
Sorbet/BlockMethodDefinition:
|
||||
Enabled: false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user