Migrate remaining no-api commands to new scoped system
This commit is contained in:
		
							parent
							
								
									52967ee53e
								
							
						
					
					
						commit
						bb7aef85db
					
				@ -862,6 +862,7 @@ fi
 | 
			
		||||
AUTO_UPDATE_CASK_TAP_COMMANDS=(
 | 
			
		||||
  bump
 | 
			
		||||
  bump-cask-pr
 | 
			
		||||
  bump-unversioned-casks
 | 
			
		||||
)
 | 
			
		||||
if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CASK_TAP_COMMANDS[@]}"
 | 
			
		||||
then
 | 
			
		||||
@ -896,37 +897,6 @@ if [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.sh" ]] ||
 | 
			
		||||
   [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${HOMEBREW_COMMAND}.rb" ]]
 | 
			
		||||
then
 | 
			
		||||
  export HOMEBREW_DEVELOPER_COMMAND="1"
 | 
			
		||||
 | 
			
		||||
  if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
 | 
			
		||||
  then
 | 
			
		||||
    NO_INSTALL_FROM_API_COMMANDS=(
 | 
			
		||||
      bottle
 | 
			
		||||
      bump-cask-pr
 | 
			
		||||
      bump-formula-pr
 | 
			
		||||
      bump-revision
 | 
			
		||||
      bump-unversioned-casks
 | 
			
		||||
      bump
 | 
			
		||||
      cat
 | 
			
		||||
      create
 | 
			
		||||
      edit
 | 
			
		||||
      extract
 | 
			
		||||
      formula
 | 
			
		||||
      generate-cask-api
 | 
			
		||||
      generate-formula-api
 | 
			
		||||
      livecheck
 | 
			
		||||
      pr-pull
 | 
			
		||||
      pr-upload
 | 
			
		||||
      update-python-resources
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    if check-array-membership "${HOMEBREW_COMMAND}" "${NO_INSTALL_FROM_API_COMMANDS[@]}"
 | 
			
		||||
    then
 | 
			
		||||
      export HOMEBREW_NO_INSTALL_FROM_API=1
 | 
			
		||||
      export HOMEBREW_AUTOMATICALLY_SET_NO_INSTALL_FROM_API=1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    unset NO_INSTALL_FROM_API_COMMANDS
 | 
			
		||||
  fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ -n "${HOMEBREW_DEVELOPER_COMMAND}" && -z "${HOMEBREW_DEVELOPER}" ]]
 | 
			
		||||
 | 
			
		||||
@ -98,7 +98,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--formula", "--cask"
 | 
			
		||||
      conflicts "--installed", "--all"
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :cask]
 | 
			
		||||
      named_args [:formula, :cask], without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -123,7 +123,7 @@ module Homebrew
 | 
			
		||||
    ENV.activate_extensions!
 | 
			
		||||
    ENV.setup_build_environment
 | 
			
		||||
 | 
			
		||||
    audit_formulae, audit_casks = with_no_api_env do # audit requires full Ruby source
 | 
			
		||||
    audit_formulae, audit_casks = Homebrew.with_no_api_env do # audit requires full Ruby source
 | 
			
		||||
      if args.tap
 | 
			
		||||
        Tap.fetch(args.tap).then do |tap|
 | 
			
		||||
          [
 | 
			
		||||
@ -217,7 +217,7 @@ module Homebrew
 | 
			
		||||
          # Audit requires full Ruby source so disable API.
 | 
			
		||||
          # We shouldn't do this for taps however so that we don't unnecessarily require a full Homebrew/core clone.
 | 
			
		||||
          fa = if f.core_formula?
 | 
			
		||||
            with_no_api_env(&audit_proc)
 | 
			
		||||
            Homebrew.with_no_api_env(&audit_proc)
 | 
			
		||||
          else
 | 
			
		||||
            audit_proc.call
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
@ -86,7 +86,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      conflicts "--no-rebuild", "--keep-old"
 | 
			
		||||
 | 
			
		||||
      named_args [:installed_formula, :file], min: 1
 | 
			
		||||
      named_args [:installed_formula, :file], min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -311,6 +311,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      tap = CoreTap.instance
 | 
			
		||||
    end
 | 
			
		||||
    raise TapUnavailableError, tap.name unless tap.installed?
 | 
			
		||||
 | 
			
		||||
    return ofail "Formula has no stable version: #{formula.full_name}" unless formula.stable
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -52,7 +52,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--dry-run", "--write"
 | 
			
		||||
      conflicts "--no-audit", "--online"
 | 
			
		||||
 | 
			
		||||
      named_args :cask, number: 1
 | 
			
		||||
      named_args :cask, number: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -85,7 +85,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--no-audit", "--online"
 | 
			
		||||
      conflicts "--url", "--tag"
 | 
			
		||||
 | 
			
		||||
      named_args :formula, max: 1
 | 
			
		||||
      named_args :formula, max: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      conflicts "--dry-run", "--write-only"
 | 
			
		||||
 | 
			
		||||
      named_args :formula, min: 1
 | 
			
		||||
      named_args :formula, min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ module Homebrew
 | 
			
		||||
      flag   "--state-file=",
 | 
			
		||||
             description: "File for caching state."
 | 
			
		||||
 | 
			
		||||
      named_args [:cask, :tap], min: 1
 | 
			
		||||
      named_args [:cask, :tap], min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--cask", "--formula"
 | 
			
		||||
      conflicts "--no-pull-requests", "--open-pr"
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :cask]
 | 
			
		||||
      named_args [:formula, :cask], without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      conflicts "--formula", "--cask"
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :cask], min: 1
 | 
			
		||||
      named_args [:formula, :cask], min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -188,6 +188,7 @@ module Homebrew
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      Homebrew.with_no_api_env do
 | 
			
		||||
        if Formula.aliases.include? fc.name
 | 
			
		||||
          realname = Formulary.canonical_name(fc.name)
 | 
			
		||||
          odie <<~EOS
 | 
			
		||||
@ -197,10 +198,14 @@ module Homebrew
 | 
			
		||||
          EOS
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    fc.generate!
 | 
			
		||||
 | 
			
		||||
    PyPI.update_python_resources! Formula[fc.name], ignore_non_pypi_packages: true if args.python?
 | 
			
		||||
    formula = Homebrew.with_no_api_env do
 | 
			
		||||
      Formula[fc.name]
 | 
			
		||||
    end
 | 
			
		||||
    PyPI.update_python_resources! formula, ignore_non_pypi_packages: true if args.python?
 | 
			
		||||
 | 
			
		||||
    puts "Please run `brew audit --new #{fc.name}` before submitting, thanks."
 | 
			
		||||
    fc.path
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      conflicts "--formula", "--cask"
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :cask]
 | 
			
		||||
      named_args [:formula, :cask], without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -76,10 +76,9 @@ module Homebrew
 | 
			
		||||
      end.presence
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if Homebrew::EnvConfig.automatically_set_no_install_from_api? &&
 | 
			
		||||
       !Homebrew::EnvConfig.no_env_hints?
 | 
			
		||||
    if !Homebrew::EnvConfig.no_install_from_api? && !Homebrew::EnvConfig.no_env_hints?
 | 
			
		||||
      paths.each do |path|
 | 
			
		||||
        next if !path.fnmatch?("**/homebrew-core/Formula/**/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/**/*.rb")
 | 
			
		||||
        next if !path.fnmatch?("**/homebrew-core/Formula/*.rb") && !path.fnmatch?("**/homebrew-cask/Casks/*.rb")
 | 
			
		||||
 | 
			
		||||
        opoo <<~EOS
 | 
			
		||||
          Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
 | 
			
		||||
 | 
			
		||||
@ -88,7 +88,7 @@ module Homebrew
 | 
			
		||||
      switch "-f", "--force",
 | 
			
		||||
             description: "Overwrite the destination formula if it already exists."
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :tap], number: 2
 | 
			
		||||
      named_args [:formula, :tap], number: 2, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -98,11 +98,11 @@ module Homebrew
 | 
			
		||||
    if (match = args.named.first.match(HOMEBREW_TAP_FORMULA_REGEX))
 | 
			
		||||
      name = match[3].downcase
 | 
			
		||||
      source_tap = Tap.fetch(match[1], match[2])
 | 
			
		||||
      raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed?
 | 
			
		||||
    else
 | 
			
		||||
      name = args.named.first.downcase
 | 
			
		||||
      source_tap = CoreTap.instance
 | 
			
		||||
    end
 | 
			
		||||
    raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed?
 | 
			
		||||
 | 
			
		||||
    destination_tap = Tap.fetch(args.named.second)
 | 
			
		||||
    unless Homebrew::EnvConfig.developer?
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ module Homebrew
 | 
			
		||||
        Display the path where <formula> is located.
 | 
			
		||||
      EOS
 | 
			
		||||
 | 
			
		||||
      named_args :formula, min: 1
 | 
			
		||||
      named_args :formula, min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,6 +43,7 @@ module Homebrew
 | 
			
		||||
    args = generate_cask_api_args.parse
 | 
			
		||||
 | 
			
		||||
    tap = Tap.default_cask_tap
 | 
			
		||||
    raise TapUnavailableError, tap.name unless tap.installed?
 | 
			
		||||
 | 
			
		||||
    unless args.dry_run?
 | 
			
		||||
      directories = ["_data/cask", "api/cask", "api/cask-source", "cask"].freeze
 | 
			
		||||
@ -50,6 +51,7 @@ module Homebrew
 | 
			
		||||
      FileUtils.mkdir_p directories
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Homebrew.with_no_api_env do
 | 
			
		||||
      Cask::Cask.generating_hash!
 | 
			
		||||
 | 
			
		||||
      tap.cask_files.each do |path|
 | 
			
		||||
@ -68,4 +70,5 @@ module Homebrew
 | 
			
		||||
        raise
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,7 @@ module Homebrew
 | 
			
		||||
    args = generate_formula_api_args.parse
 | 
			
		||||
 | 
			
		||||
    tap = CoreTap.instance
 | 
			
		||||
    raise TapUnavailableError, tap.name unless tap.installed?
 | 
			
		||||
 | 
			
		||||
    unless args.dry_run?
 | 
			
		||||
      directories = ["_data/formula", "api/formula", "formula"]
 | 
			
		||||
@ -51,6 +52,7 @@ module Homebrew
 | 
			
		||||
      FileUtils.mkdir_p directories
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Homebrew.with_no_api_env do
 | 
			
		||||
      Formulary.enable_factory_cache!
 | 
			
		||||
      Formula.generating_hash!
 | 
			
		||||
 | 
			
		||||
@ -72,4 +74,5 @@ module Homebrew
 | 
			
		||||
      canonical_json = JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table))
 | 
			
		||||
      File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -48,7 +48,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--tap=", "--eval-all", "--installed"
 | 
			
		||||
      conflicts "--cask", "--formula"
 | 
			
		||||
 | 
			
		||||
      named_args [:formula, :cask]
 | 
			
		||||
      named_args [:formula, :cask], without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -66,7 +66,8 @@ module Homebrew
 | 
			
		||||
      puts Homebrew::EnvConfig.livecheck_watchlist if Homebrew::EnvConfig.livecheck_watchlist.present?
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    formulae_and_casks_to_check = if args.tap
 | 
			
		||||
    formulae_and_casks_to_check = Homebrew.with_no_api_env do
 | 
			
		||||
      if args.tap
 | 
			
		||||
        tap = Tap.fetch(args.tap)
 | 
			
		||||
        formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
 | 
			
		||||
        casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
 | 
			
		||||
@ -101,6 +102,7 @@ module Homebrew
 | 
			
		||||
      else
 | 
			
		||||
        raise UsageError, "A watchlist file is required when no arguments are given."
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    formulae_and_casks_to_check = formulae_and_casks_to_check.sort_by do |formula_or_cask|
 | 
			
		||||
      formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
 | 
			
		||||
 | 
			
		||||
@ -414,6 +414,7 @@ module Homebrew
 | 
			
		||||
    workflows = args.workflows.presence || ["tests.yml"]
 | 
			
		||||
    artifact = args.artifact || "bottles"
 | 
			
		||||
    tap = Tap.fetch(args.tap || CoreTap.instance.name)
 | 
			
		||||
    raise TapUnavailableError, tap.name unless tap.installed?
 | 
			
		||||
 | 
			
		||||
    Utils::Git.set_name_email!(committer: args.committer.blank?)
 | 
			
		||||
    Utils::Git.setup_gpg!
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,7 @@ module Homebrew
 | 
			
		||||
      conflicts "--formula", "--cask"
 | 
			
		||||
      conflicts "--only-cops", "--except-cops"
 | 
			
		||||
 | 
			
		||||
      named_args [:file, :tap, :formula, :cask]
 | 
			
		||||
      named_args [:file, :tap, :formula, :cask], without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ module Homebrew
 | 
			
		||||
      comma_array "--exclude-packages",
 | 
			
		||||
                  description: "Exclude these packages when finding resources."
 | 
			
		||||
 | 
			
		||||
      named_args :formula, min: 1
 | 
			
		||||
      named_args :formula, min: 1, without_api: true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user