Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 11 additions & 49 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,6 @@ def full_specified_name
full_alias_name || full_name
end

# The name specified to install this formula.
sig { returns(String) }
def installed_specified_name
installed_alias_name || name
end

# The name (including tap) specified to install this formula.
sig { returns(String) }
def full_installed_specified_name
Expand Down Expand Up @@ -748,16 +742,6 @@ def full_formulae_names
formula_names_for_glob("#{sibling_name}.rb")
end

# Returns sibling `-full` or non-`-full` Formula objects for any Formula.
sig { returns(T::Array[Formula]) }
def full_formulae
full_formulae_names.filter_map do |formula_name|
Formula[formula_name]
rescue FormulaUnavailableError
nil
end.sort_by(&:version).reverse
end

sig { returns(T.nilable(String)) }
def link_overwrite_reason
installed_overwrite_formulae = link_overwrite_formulae.select(&:any_version_installed?)
Expand Down Expand Up @@ -1068,14 +1052,6 @@ def linked? = linked_keg.exist?
sig { returns(T::Boolean) }
def optlinked? = opt_prefix.symlink?

# If a formula's linked keg points to the prefix.
sig { params(version: T.any(String, PkgVersion)).returns(T::Boolean) }
def prefix_linked?(version = pkg_version)
return false unless linked?

linked_keg.resolved_path == versioned_prefix(version)
end

# {PkgVersion} of the linked keg for the formula.
sig { returns(T.nilable(PkgVersion)) }
def linked_version
Expand Down Expand Up @@ -2627,12 +2603,6 @@ def self.installed_with_alias_path(alias_path)
installed.select { |f| f.installed_alias_path == alias_path }
end

# An array of all alias files of core {Formula}e.
sig { returns(T::Array[Pathname]) }
def self.core_alias_files
CoreTap.instance.alias_files
end

# An array of all core aliases.
sig { returns(T::Array[String]) }
def self.core_aliases
Expand Down Expand Up @@ -3247,25 +3217,6 @@ def dependencies_hash
hash
end

sig { params(spec_symbol: Symbol).returns(T.nilable(T::Hash[String, T.untyped])) }
def internal_dependencies_hash(spec_symbol)
raise ArgumentError, "Unsupported spec: #{spec_symbol}" unless [:stable, :head].include?(spec_symbol)
return unless (spec = public_send(spec_symbol))

spec.declared_deps.each_with_object({}) do |dep, dep_hash|
# Implicit dependencies are only needed when installing from source
# since they are only used to download and unpack source files.
# @see DependencyCollector
next if dep.implicit?

metadata_hash = {}
metadata_hash[:tags] = dep.tags if dep.tags.present?
metadata_hash[:uses_from_macos] = dep.bounds.presence if dep.uses_from_macos?

dep_hash[dep.name] = metadata_hash.presence
end
end

sig { returns(T.nilable(T::Boolean)) }
def on_system_blocks_exist?
self.class.on_system_blocks_exist? || @on_system_blocks_exist
Expand Down Expand Up @@ -3333,6 +3284,9 @@ def test_defined?
}
def test; end

# Returns the path to a fixture file for use in formula tests.
#
# @api public
sig { params(file: T.any(Pathname, String)).returns(Pathname) }
def test_fixtures(file)
HOMEBREW_LIBRARY_PATH/"test/support/fixtures"/file
Expand Down Expand Up @@ -3665,6 +3619,8 @@ def mkdir(name, &block)
end

# Runs `xcodebuild` without Homebrew's compiler environment variables set.
#
# @api public
sig { params(args: T.any(String, Integer, Pathname, Symbol)).void }
def xcodebuild(*args)
removed = ENV.remove_cc_etc
Expand Down Expand Up @@ -3969,6 +3925,8 @@ def license(args = nil)
# ```ruby
# allow_network_access! [:build, :test]
# ```
#
# @api public
sig { params(phases: T.any(Symbol, T::Array[Symbol])).void }
def allow_network_access!(phases = [])
phases_array = Array(phases)
Expand Down Expand Up @@ -4001,6 +3959,8 @@ def allow_network_access!(phases = [])
# ```ruby
# deny_network_access! [:build, :test]
# ```
#
# @api public
sig { params(phases: T.any(Symbol, T::Array[Symbol])).void }
def deny_network_access!(phases = [])
phases_array = Array(phases)
Expand Down Expand Up @@ -4371,6 +4331,8 @@ def head(val = nil, specs = {}, &block)
# # Special case: empty `package_name` allows to skip resource updates for non-extra packages
# pypi_packages package_name: "", extra_packages: "setuptools"
# ```
#
# @api public
sig {
params(
package_name: T.nilable(String),
Expand Down
32 changes: 0 additions & 32 deletions Library/Homebrew/test/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,34 +261,6 @@
end
end

describe "#full_formulae" do
let(:f) do
formula "foo" do
T.bind(self, T.class_of(Formula))
url "foo-1.0"
end
end

let(:f_full) do
formula "foo-full" do
T.bind(self, T.class_of(Formula))
url "foo-full-1.0"
end
end

before do
allow(Formulary).to receive(:load_formula_from_path).with(f_full.name, f_full.path).and_return(f_full)
allow(Formulary).to receive(:factory).with(f_full.name).and_return(f_full)
allow(f).to receive(:full_formulae_names).and_return([f_full.name])
end

it "returns array with sibling full formulae" do
FileUtils.touch f.path
FileUtils.touch f_full.path
expect(f.full_formulae).to eq [f_full]
end
end

describe "#unversioned_formula_name" do
let(:f) do
formula "foo" do
Expand Down Expand Up @@ -565,7 +537,6 @@
expect(f.installed_alias_path).to be_nil
expect(f.installed_alias_name).to be_nil
expect(f.full_installed_alias_name).to be_nil
expect(f.installed_specified_name).to eq(f.name)
expect(f.full_installed_specified_name).to eq(f.name)
end

Expand All @@ -579,7 +550,6 @@
expect(f.installed_alias_path).to eq(alias_path)
expect(f.installed_alias_name).to eq(alias_name)
expect(f.full_installed_alias_name).to eq(alias_name)
expect(f.installed_specified_name).to eq(alias_name)
expect(f.full_installed_specified_name).to eq(alias_name)
end

Expand All @@ -601,7 +571,6 @@
expect(f.installed_alias_path).to be_nil
expect(f.installed_alias_name).to be_nil
expect(f.full_installed_alias_name).to be_nil
expect(f.installed_specified_name).to eq(f.name)
expect(f.full_installed_specified_name).to eq(f.full_name)
end

Expand All @@ -616,7 +585,6 @@
expect(f.installed_alias_path).to eq(alias_path)
expect(f.installed_alias_name).to eq(alias_name)
expect(f.full_installed_alias_name).to eq(full_alias_name)
expect(f.installed_specified_name).to eq(alias_name)
expect(f.full_installed_specified_name).to eq(full_alias_name)

FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/user"
Expand Down
Loading