Merge pull request #20358 from Homebrew/require-formula-ensure-formula-installed
Ensure we `require "formula"` before doing `ensure_formula_installed!`
This commit is contained in:
commit
9dc111247f
@ -135,7 +135,10 @@ module Homebrew
|
|||||||
|
|
||||||
if args.repology? && !Utils::Curl.curl_supports_tls13?
|
if args.repology? && !Utils::Curl.curl_supports_tls13?
|
||||||
begin
|
begin
|
||||||
ensure_formula_installed!("curl", reason: "Repology queries") unless HOMEBREW_BREWED_CURL_PATH.exist?
|
unless HOMEBREW_BREWED_CURL_PATH.exist?
|
||||||
|
require "formula"
|
||||||
|
ensure_formula_installed!("curl", reason: "Repology queries")
|
||||||
|
end
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
opoo "A newer `curl` is required for Repology queries."
|
opoo "A newer `curl` is required for Repology queries."
|
||||||
end
|
end
|
||||||
|
|||||||
@ -441,6 +441,8 @@ module Kernel
|
|||||||
|
|
||||||
# Ensure the given formula is installed
|
# Ensure the given formula is installed
|
||||||
# This is useful for installing a utility formula (e.g. `shellcheck` for `brew style`)
|
# This is useful for installing a utility formula (e.g. `shellcheck` for `brew style`)
|
||||||
|
# NOTE: One must `require "formula"` before using this method. Doing `require "formula"` inside the method
|
||||||
|
# doesn't help, and therefore is useless to add.
|
||||||
sig {
|
sig {
|
||||||
params(formula_name: String, reason: String, latest: T::Boolean, output_to_stderr: T::Boolean,
|
params(formula_name: String, reason: String, latest: T::Boolean, output_to_stderr: T::Boolean,
|
||||||
quiet: T::Boolean).returns(Formula)
|
quiet: T::Boolean).returns(Formula)
|
||||||
@ -460,8 +462,8 @@ module Kernel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require "formula"
|
# Do not `require "formula"` here. It will mask misuse of this method when
|
||||||
|
# it is called without doing `require "formula"` first.
|
||||||
formula = Formula[formula_name]
|
formula = Formula[formula_name]
|
||||||
reason = " for #{reason}" if reason.present?
|
reason = " for #{reason}" if reason.present?
|
||||||
|
|
||||||
@ -493,6 +495,7 @@ module Kernel
|
|||||||
].compact.first
|
].compact.first
|
||||||
return executable if executable.exist?
|
return executable if executable.exist?
|
||||||
|
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!(formula_name, reason:, latest:).opt_bin/name
|
ensure_formula_installed!(formula_name, reason:, latest:).opt_bin/name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -320,23 +320,21 @@ module Homebrew
|
|||||||
HOMEBREW_REPOSITORY.glob(".github/workflows/*.yml")
|
HOMEBREW_REPOSITORY.glob(".github/workflows/*.yml")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rubocop
|
|
||||||
ensure_formula_installed!("rubocop", latest: true,
|
|
||||||
reason: "Ruby style checks").opt_bin/"rubocop"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.shellcheck
|
def self.shellcheck
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!("shellcheck", latest: true,
|
ensure_formula_installed!("shellcheck", latest: true,
|
||||||
reason: "shell style checks").opt_bin/"shellcheck"
|
reason: "shell style checks").opt_bin/"shellcheck"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.shfmt
|
def self.shfmt
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!("shfmt", latest: true,
|
ensure_formula_installed!("shfmt", latest: true,
|
||||||
reason: "formatting shell scripts")
|
reason: "formatting shell scripts")
|
||||||
HOMEBREW_LIBRARY/"Homebrew/utils/shfmt.sh"
|
HOMEBREW_LIBRARY/"Homebrew/utils/shfmt.sh"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.actionlint
|
def self.actionlint
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!("actionlint", latest: true,
|
ensure_formula_installed!("actionlint", latest: true,
|
||||||
reason: "GitHub Actions checks").opt_bin/"actionlint"
|
reason: "GitHub Actions checks").opt_bin/"actionlint"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -103,6 +103,7 @@ module Utils
|
|||||||
# and will also likely fail due to `OS::Linux` and `OS::Mac` being undefined.
|
# and will also likely fail due to `OS::Linux` and `OS::Mac` being undefined.
|
||||||
raise "Refusing to install Git on a generic OS." if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
raise "Refusing to install Git on a generic OS." if ENV["HOMEBREW_TEST_GENERIC_OS"]
|
||||||
|
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!("git")
|
ensure_formula_installed!("git")
|
||||||
clear_available_cache
|
clear_available_cache
|
||||||
rescue
|
rescue
|
||||||
|
|||||||
@ -152,6 +152,7 @@ module PyPI
|
|||||||
@extras ||= T.let([], T.nilable(T::Array[String]))
|
@extras ||= T.let([], T.nilable(T::Array[String]))
|
||||||
@version ||= T.let(match[2], T.nilable(String))
|
@version ||= T.let(match[2], T.nilable(String))
|
||||||
elsif @is_url
|
elsif @is_url
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!(@python_name)
|
ensure_formula_installed!(@python_name)
|
||||||
|
|
||||||
# The URL might be a source distribution hosted somewhere;
|
# The URL might be a source distribution hosted somewhere;
|
||||||
@ -260,6 +261,7 @@ module PyPI
|
|||||||
missing_msg = "formulae required to update \"#{formula.name}\" resources: #{missing_dependencies.join(", ")}"
|
missing_msg = "formulae required to update \"#{formula.name}\" resources: #{missing_dependencies.join(", ")}"
|
||||||
odie "Missing #{missing_msg}" unless install_dependencies
|
odie "Missing #{missing_msg}" unless install_dependencies
|
||||||
ohai "Installing #{missing_msg}"
|
ohai "Installing #{missing_msg}"
|
||||||
|
require "formula"
|
||||||
missing_dependencies.each(&:ensure_formula_installed!)
|
missing_dependencies.each(&:ensure_formula_installed!)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -334,6 +336,7 @@ module PyPI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "formula"
|
||||||
ensure_formula_installed!(python_name)
|
ensure_formula_installed!(python_name)
|
||||||
|
|
||||||
# Resolve the dependency tree of all input packages
|
# Resolve the dependency tree of all input packages
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user