tap: warn if tapping core taps under API mode

This commit is contained in:
Bo Anderson 2023-07-05 19:15:48 +01:00
parent 66fc022106
commit 8d1aabba81
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
8 changed files with 25 additions and 5 deletions

View File

@ -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; } \

View File

@ -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

View File

@ -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

View File

@ -2081,6 +2081,7 @@ _brew_tap() {
--custom-remote
--debug
--eval-all
--force
--force-auto-update
--help
--list-pinned

View File

@ -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'

View File

@ -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]' \

View File

@ -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`* ...]

View File

@ -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\.
.