Merge pull request #13440 from Rylan12/prefer-api-to-taps

Always prefer loading from API when `HOMEBREW_INSTALL_FROM_API` is set
This commit is contained in:
Rylan Polster 2022-06-21 10:18:02 -04:00 committed by GitHub
commit b941470216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 17 deletions

View File

@ -217,14 +217,17 @@ module Cask
next unless loader_class.can_load?(ref) next unless loader_class.can_load?(ref)
if loader_class == FromTapLoader && Homebrew::EnvConfig.install_from_api? && if loader_class == FromTapLoader && Homebrew::EnvConfig.install_from_api? &&
ref.start_with?("homebrew/cask/") && !Tap.fetch("homebrew/cask").installed? && ref.start_with?("homebrew/cask/") && Homebrew::API::CaskSource.available?(ref)
Homebrew::API::CaskSource.available?(ref)
return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref)) return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref))
end end
return loader_class.new(ref) return loader_class.new(ref)
end end
if Homebrew::EnvConfig.install_from_api? && Homebrew::API::CaskSource.available?(ref)
return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref))
end
return FromTapPathLoader.new(default_path(ref)) if FromTapPathLoader.can_load?(default_path(ref)) return FromTapPathLoader.new(default_path(ref)) if FromTapPathLoader.can_load?(default_path(ref))
case (possible_tap_casks = tap_paths(ref)).count case (possible_tap_casks = tap_paths(ref)).count
@ -239,10 +242,6 @@ module Cask
EOS EOS
end end
if Homebrew::EnvConfig.install_from_api? && Homebrew::API::CaskSource.available?(ref)
return FromContentLoader.new(Homebrew::API::CaskSource.fetch(ref))
end
possible_installed_cask = Cask.new(ref) possible_installed_cask = Cask.new(ref)
return FromPathLoader.new(possible_installed_cask.installed_caskfile) if possible_installed_cask.installed? return FromPathLoader.new(possible_installed_cask.installed_caskfile) if possible_installed_cask.installed?

View File

@ -149,7 +149,7 @@ module Homebrew
updated_taps = [] updated_taps = []
Tap.each do |tap| Tap.each do |tap|
next unless tap.git? next unless tap.git?
next if (tap.core_tap? || tap == "homebrew/cask") && Homebrew::EnvConfig.install_from_api? && args.auto_update? next if (tap.core_tap? || tap == "homebrew/cask") && Homebrew::EnvConfig.install_from_api?
if ENV["HOMEBREW_MIGRATE_LINUXBREW_FORMULAE"].present? && tap.core_tap? && if ENV["HOMEBREW_MIGRATE_LINUXBREW_FORMULAE"].present? && tap.core_tap? &&
Settings.read("linuxbrewmigrated") != "true" Settings.read("linuxbrewmigrated") != "true"

View File

@ -701,10 +701,7 @@ EOS
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/* for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do do
# HOMEBREW_UPDATE_AUTO wasn't modified in subshell.
# shellcheck disable=SC2031
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] && if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || [[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]] "${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
then then

View File

@ -641,7 +641,7 @@ module Formulary
when URL_START_REGEX when URL_START_REGEX
return FromUrlLoader.new(ref) return FromUrlLoader.new(ref)
when HOMEBREW_TAP_FORMULA_REGEX when HOMEBREW_TAP_FORMULA_REGEX
if ref.start_with?("homebrew/core/") && !CoreTap.instance.installed? && Homebrew::EnvConfig.install_from_api? if ref.start_with?("homebrew/core/") && Homebrew::EnvConfig.install_from_api?
name = ref.split("/", 3).last name = ref.split("/", 3).last
return FormulaAPILoader.new(name) if Homebrew::API::Formula.all_formulae.key?(name) return FormulaAPILoader.new(name) if Homebrew::API::Formula.all_formulae.key?(name)
end end
@ -651,18 +651,16 @@ module Formulary
return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist? return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist?
if Homebrew::EnvConfig.install_from_api? && Homebrew::API::Formula.all_formulae.key?(ref)
return FormulaAPILoader.new(ref)
end
formula_with_that_name = core_path(ref) formula_with_that_name = core_path(ref)
return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file? return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file?
possible_alias = CoreTap.instance.alias_dir/ref possible_alias = CoreTap.instance.alias_dir/ref
return AliasLoader.new(possible_alias) if possible_alias.file? return AliasLoader.new(possible_alias) if possible_alias.file?
if !CoreTap.instance.installed? &&
Homebrew::EnvConfig.install_from_api? &&
Homebrew::API::Formula.all_formulae.key?(ref)
return FormulaAPILoader.new(ref)
end
possible_tap_formulae = tap_paths(ref) possible_tap_formulae = tap_paths(ref)
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1 raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1