diff --git a/Dockerfile b/Dockerfile index e754e52443..5c92a9a0f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,7 @@ RUN mkdir -p \ && ln -s ../Homebrew/bin/brew .linuxbrew/bin/brew \ && git -C .linuxbrew/Homebrew remote set-url origin https://github.com/Homebrew/brew \ && git -C .linuxbrew/Homebrew fetch origin \ - && HOMEBREW_NO_ANALYTICS=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/core \ + && HOMEBREW_NO_ANALYTICS=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap --force homebrew/core \ && brew install-bundler-gems \ && brew cleanup \ && { git -C .linuxbrew/Homebrew config --unset gc.auto; true; } \ diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 7b1a9c1259..ac46e0f93e 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -46,6 +46,8 @@ module Homebrew switch "--eval-all", description: "Evaluate all the formulae, casks and aliases in the new tap to check validity. " \ "Implied if `HOMEBREW_EVAL_ALL` is set." + switch "--force", + description: "Force install core taps even under API mode." named_args :tap, max: 2 end @@ -69,7 +71,8 @@ module Homebrew force_auto_update: args.force_auto_update?, custom_remote: args.custom_remote?, quiet: args.quiet?, - verify: args.eval_all? || Homebrew::EnvConfig.eval_all? + verify: args.eval_all? || Homebrew::EnvConfig.eval_all?, + force: args.force? rescue TapRemoteMismatchError, TapNoCustomRemoteError => e odie e rescue TapAlreadyTappedError diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index fb0f8284ae..52bd9d6bc6 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -253,7 +253,9 @@ class Tap # @param quiet [Boolean] If set, suppress all output. # @param custom_remote [Boolean] If set, change the tap's remote if already installed. # @param verify [Boolean] If set, verify all the formula, casks and aliases in the tap are valid. - def install(quiet: false, clone_target: nil, force_auto_update: nil, custom_remote: false, verify: false) + # @param force [Boolean] If set, force core and cask taps to install even under API mode. + def install(quiet: false, clone_target: nil, force_auto_update: nil, + custom_remote: false, verify: false, force: false) require "descriptions" require "readall" @@ -297,6 +299,10 @@ class Tap args << "-q" if quiet path.cd { safe_system "git", *args } return + elsif (core_tap? || name == "homebrew/cask") && !Homebrew::EnvConfig.no_install_from_api? && !force + # odeprecated: move to odie in the next minor release. This may break some CI so we should give notice. + opoo "Tapping #{name} is no longer typically necessary.\n" \ + "Add #{Formatter.option("--force")} if you are sure you need one." end clear_cache @@ -898,7 +904,8 @@ class CoreTap < Tap end # CoreTap never allows shallow clones (on request from GitHub). - def install(quiet: false, clone_target: nil, force_auto_update: nil, custom_remote: false, verify: false) + def install(quiet: false, clone_target: nil, force_auto_update: nil, + custom_remote: false, verify: false, force: false) remote = Homebrew::EnvConfig.core_git_remote # set by HOMEBREW_CORE_GIT_REMOTE requested_remote = clone_target || remote @@ -909,7 +916,8 @@ class CoreTap < Tap $stderr.puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} as the Homebrew/homebrew-core Git remote." end - super(quiet: quiet, clone_target: remote, force_auto_update: force_auto_update, custom_remote: custom_remote) + super(quiet: quiet, clone_target: remote, force_auto_update: force_auto_update, + custom_remote: custom_remote, force: force) end # @private diff --git a/completions/bash/brew b/completions/bash/brew index a34a6399d0..2f064c72c0 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -2081,6 +2081,7 @@ _brew_tap() { --custom-remote --debug --eval-all + --force --force-auto-update --help --list-pinned diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index a565c3154c..b9963a96e1 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -1395,6 +1395,7 @@ __fish_brew_complete_cmd 'tap' 'Tap a formula repository' __fish_brew_complete_arg 'tap' -l custom-remote -d 'Install or change a tap with a custom remote. Useful for mirrors' __fish_brew_complete_arg 'tap' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'tap' -l eval-all -d 'Evaluate all the formulae, casks and aliases in the new tap to check validity. Implied if `HOMEBREW_EVAL_ALL` is set' +__fish_brew_complete_arg 'tap' -l force -d 'Force install core taps even under API mode' __fish_brew_complete_arg 'tap' -l force-auto-update -d 'Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)' __fish_brew_complete_arg 'tap' -l help -d 'Show this message' __fish_brew_complete_arg 'tap' -l list-pinned -d 'List all pinned taps' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 6fc4addd80..62654ac1ef 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1721,6 +1721,7 @@ _brew_tap() { '--custom-remote[Install or change a tap with a custom remote. Useful for mirrors]' \ '--debug[Display any debugging information]' \ '--eval-all[Evaluate all the formulae, casks and aliases in the new tap to check validity. Implied if `HOMEBREW_EVAL_ALL` is set]' \ + '--force[Force install core taps even under API mode]' \ '--force-auto-update[Auto-update tap even if it is not hosted on GitHub. By default, only taps hosted on GitHub are auto-updated (for performance reasons)]' \ '--help[Show this message]' \ '--list-pinned[List all pinned taps]' \ diff --git a/docs/Manpage.md b/docs/Manpage.md index fbeb6fa45a..ff1a38211d 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -692,6 +692,8 @@ using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. List all pinned taps. * `--eval-all`: Evaluate all the formulae, casks and aliases in the new tap to check validity. Implied if `HOMEBREW_EVAL_ALL` is set. +* `--force`: + Force install core taps even under API mode. ### `tap-info` [`--installed`] [`--json`] [*`tap`* ...] diff --git a/manpages/brew.1 b/manpages/brew.1 index ab11be8c9f..10540bed32 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -973,6 +973,10 @@ List all pinned taps\. \fB\-\-eval\-all\fR Evaluate all the formulae, casks and aliases in the new tap to check validity\. Implied if \fBHOMEBREW_EVAL_ALL\fR is set\. . +.TP +\fB\-\-force\fR +Force install core taps even under API mode\. +. .SS "\fBtap\-info\fR [\fB\-\-installed\fR] [\fB\-\-json\fR] [\fItap\fR \.\.\.]" Show detailed information about one or more \fItap\fRs\. .