Merge pull request #15744 from dduugg/formula-type-fix
Fix type error when running 'brew doctor'
This commit is contained in:
commit
4e168a1588
@ -367,9 +367,9 @@ class Formula
|
|||||||
|
|
||||||
# Is this formula HEAD-only?
|
# Is this formula HEAD-only?
|
||||||
# @private
|
# @private
|
||||||
sig { returns(T.nilable(T::Boolean)) }
|
sig { returns(T::Boolean) }
|
||||||
def head_only?
|
def head_only?
|
||||||
head && !stable
|
!!head && !stable
|
||||||
end
|
end
|
||||||
|
|
||||||
delegate [ # rubocop:disable Layout/HashAlignment
|
delegate [ # rubocop:disable Layout/HashAlignment
|
||||||
@ -437,6 +437,7 @@ class Formula
|
|||||||
# @see .loaded_from_api?
|
# @see .loaded_from_api?
|
||||||
delegate loaded_from_api?: :"self.class"
|
delegate loaded_from_api?: :"self.class"
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def update_head_version
|
def update_head_version
|
||||||
return unless head?
|
return unless head?
|
||||||
return unless head.downloader.is_a?(VCSDownloadStrategy)
|
return unless head.downloader.is_a?(VCSDownloadStrategy)
|
||||||
@ -502,12 +503,14 @@ class Formula
|
|||||||
|
|
||||||
# An old name for the formula.
|
# An old name for the formula.
|
||||||
# @deprecated Use #{#oldnames} instead.
|
# @deprecated Use #{#oldnames} instead.
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def oldname
|
def oldname
|
||||||
odeprecated "Formula#oldname", "Formula#oldnames"
|
odeprecated "Formula#oldname", "Formula#oldnames"
|
||||||
@oldname ||= oldnames.first
|
@oldname ||= oldnames.first
|
||||||
end
|
end
|
||||||
|
|
||||||
# Old names for the formula.
|
# Old names for the formula.
|
||||||
|
sig { returns(T::Array[String]) }
|
||||||
def oldnames
|
def oldnames
|
||||||
@oldnames ||= if tap
|
@oldnames ||= if tap
|
||||||
tap.formula_renames
|
tap.formula_renames
|
||||||
@ -518,6 +521,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# All aliases for the formula.
|
# All aliases for the formula.
|
||||||
|
sig { returns(T::Array[String]) }
|
||||||
def aliases
|
def aliases
|
||||||
@aliases ||= if tap
|
@aliases ||= if tap
|
||||||
tap.alias_reverse_table[full_name].to_a.map do |a|
|
tap.alias_reverse_table[full_name].to_a.map do |a|
|
||||||
@ -1434,6 +1438,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
|
sig { returns(T::Array[String]) }
|
||||||
def oldnames_to_migrate
|
def oldnames_to_migrate
|
||||||
oldnames.select do |oldname|
|
oldnames.select do |oldname|
|
||||||
old_rack = HOMEBREW_CELLAR/oldname
|
old_rack = HOMEBREW_CELLAR/oldname
|
||||||
@ -1444,7 +1449,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T.nilable(T::Boolean)) }
|
sig { returns(T::Boolean) }
|
||||||
def migration_needed?
|
def migration_needed?
|
||||||
!oldnames_to_migrate.empty? && !rack.exist?
|
!oldnames_to_migrate.empty? && !rack.exist?
|
||||||
end
|
end
|
||||||
@ -1492,7 +1497,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_installed_alias_target
|
def current_installed_alias_target
|
||||||
Formulary.factory(installed_alias_name) if installed_alias_path
|
Formulary.factory(T.must(installed_alias_name)) if installed_alias_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# Has the target of the alias used to install this formula changed?
|
# Has the target of the alias used to install this formula changed?
|
||||||
@ -2014,9 +2019,9 @@ class Formula
|
|||||||
|
|
||||||
# True if this formula is provided by Homebrew itself
|
# True if this formula is provided by Homebrew itself
|
||||||
# @private
|
# @private
|
||||||
sig { returns(T.nilable(T::Boolean)) }
|
sig { returns(T::Boolean) }
|
||||||
def core_formula?
|
def core_formula?
|
||||||
tap&.core_tap?
|
!!tap&.core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
# True if this formula is provided by external Tap
|
# True if this formula is provided by external Tap
|
||||||
|
@ -729,9 +729,9 @@ module Formulary
|
|||||||
# * a local bottle reference
|
# * a local bottle reference
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
ref: T.nilable(T.any(Pathname, String)),
|
ref: T.any(Pathname, String),
|
||||||
spec: Symbol,
|
spec: Symbol,
|
||||||
alias_path: Pathname,
|
alias_path: T.nilable(Pathname),
|
||||||
from: Symbol,
|
from: Symbol,
|
||||||
warn: T::Boolean,
|
warn: T::Boolean,
|
||||||
force_bottle: T::Boolean,
|
force_bottle: T::Boolean,
|
||||||
@ -742,15 +742,13 @@ module Formulary
|
|||||||
def self.factory(
|
def self.factory(
|
||||||
ref,
|
ref,
|
||||||
spec = :stable,
|
spec = :stable,
|
||||||
alias_path: T.unsafe(nil),
|
alias_path: nil,
|
||||||
from: T.unsafe(nil),
|
from: T.unsafe(nil),
|
||||||
warn: T.unsafe(nil),
|
warn: T.unsafe(nil),
|
||||||
force_bottle: T.unsafe(nil),
|
force_bottle: T.unsafe(nil),
|
||||||
flags: T.unsafe(nil),
|
flags: T.unsafe(nil),
|
||||||
ignore_errors: T.unsafe(nil)
|
ignore_errors: T.unsafe(nil)
|
||||||
)
|
)
|
||||||
raise ArgumentError, "Formulae must have a ref!" unless ref
|
|
||||||
|
|
||||||
cache_key = "#{ref}-#{spec}-#{alias_path}-#{from}"
|
cache_key = "#{ref}-#{spec}-#{alias_path}-#{from}"
|
||||||
return cache[:formulary_factory][cache_key] if factory_cached? && cache[:formulary_factory]&.key?(cache_key)
|
return cache[:formulary_factory][cache_key] if factory_cached? && cache[:formulary_factory]&.key?(cache_key)
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ describe Formulary do
|
|||||||
it "raises an error if ref is nil" do
|
it "raises an error if ref is nil" do
|
||||||
expect do
|
expect do
|
||||||
described_class.factory(nil)
|
described_class.factory(nil)
|
||||||
end.to raise_error(ArgumentError)
|
end.to raise_error(TypeError)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with sharded Formula directory" do
|
context "with sharded Formula directory" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user