dev-cmd/bump: add --no-auto flag

I do not like that `brew bump` command checks every single formula/cask,
even ones updated by BrewTestBot. Instead of showing useful info about
outdated packages, my terminal buffer is fludded with `Formula is
autobumped so will have bump PRs opened by BrewTestBot every ~3 hours`.
This flag excludes autobumped packages before checking them.

Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
botantony 2025-04-02 16:40:01 +02:00
parent c7634843d7
commit e3875f790e
No known key found for this signature in database
GPG Key ID: 7FE721557EA6AAD6
2 changed files with 32 additions and 0 deletions

View File

@ -33,6 +33,8 @@ module Homebrew
switch "--auto",
description: "Read the list of formulae/casks from the tap autobump list.",
hidden: true
switch "--no-auto",
description: "Ignore formulae/casks in autobump list (official repositories only)."
switch "--formula", "--formulae",
description: "Check only formulae."
switch "--cask", "--casks",
@ -54,6 +56,7 @@ module Homebrew
conflicts "--cask", "--formula"
conflicts "--tap=", "--installed"
conflicts "--tap=", "--no-auto"
conflicts "--eval-all", "--installed"
conflicts "--installed", "--auto"
conflicts "--no-pull-requests", "--open-pr"
@ -68,6 +71,16 @@ module Homebrew
Homebrew.with_no_api_env do
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
excluded_autobump = []
if args.no_auto?
if eval_all || args.formula?
excluded_autobump.concat autobumped_formulae_or_casks Tap.fetch("homebrew/core")
end
if eval_all || args.cask?
excluded_autobump.concat autobumped_formulae_or_casks Tap.fetch("homebrew/cask"), casks: true
end
end
formulae_and_casks = if args.auto?
raise UsageError, "`--formula` or `--cask` must be passed with `--auto`." if !args.formula? && !args.cask?
@ -119,6 +132,8 @@ module Homebrew
formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
end
formulae_and_casks.delete_if { |f_or_c| excluded_autobump.include?(f_or_c) }
if args.repology? && !Utils::Curl.curl_supports_tls13?
begin
ensure_formula_installed!("curl", reason: "Repology queries") unless HOMEBREW_BREWED_CURL_PATH.exist?
@ -541,6 +556,17 @@ module Homebrew
synced_with
end
sig { params(tap: Tap, casks: T::Boolean).returns(T::Array[T.any(Formula, Cask::Cask)]) }
def autobumped_formulae_or_casks(tap, casks: false)
autobump_list = tap.autobump
autobump_list.map do |name|
qualified_name = "#{tap.name}/#{name}"
next Cask::CaskLoader.load(qualified_name) if casks
Formulary.factory(qualified_name)
end
end
end
end
end

View File

@ -14,6 +14,12 @@ class Homebrew::DevCmd::Bump::Args < Homebrew::CLI::Args
sig { returns(T::Boolean) }
def auto?; end
# `/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/bin/tapioca dsl Homebrew::DevCmd::Bump`
# didn't work for me for some reason, adding `no_auto?` flag manually.
# If you can help me with fixing the issue or `tapioca` runs perfectly, please, override this
sig { returns(T::Boolean) }
def no_auto?; end
sig { returns(T::Boolean) }
def cask?; end