From e3875f790eff146a297cb022e3d0e0e95e2ad256 Mon Sep 17 00:00:00 2001 From: botantony Date: Wed, 2 Apr 2025 16:40:01 +0200 Subject: [PATCH 1/3] 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 --- Library/Homebrew/dev-cmd/bump.rb | 26 +++++++++++++++++++ .../sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index 8e4245a91a..3eace29742 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -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 diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi index 1e750628c4..8a7501c9f3 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi @@ -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 From aa86fcc9b3bb7eaddf8e728a0e77d153977195a6 Mon Sep 17 00:00:00 2001 From: botantony Date: Wed, 2 Apr 2025 17:23:09 +0200 Subject: [PATCH 2/3] dev-cmd/bump: suggestions from MikeMcQuaid Co-authored-by: Mike McQuaid Signed-off-by: botantony --- Library/Homebrew/dev-cmd/bump.rb | 20 +++++++++---------- .../sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index 3eace29742..cfca2b2087 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -33,7 +33,7 @@ module Homebrew switch "--auto", description: "Read the list of formulae/casks from the tap autobump list.", hidden: true - switch "--no-auto", + switch "--no-autobump", description: "Ignore formulae/casks in autobump list (official repositories only)." switch "--formula", "--formulae", description: "Check only formulae." @@ -72,12 +72,10 @@ module Homebrew 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 args.no_autobump? + excluded_autobump.concat(autobumped_formulae_or_casks(CoreTap.instance)) if eval_all || args.formula? if eval_all || args.cask? - excluded_autobump.concat autobumped_formulae_or_casks Tap.fetch("homebrew/cask"), casks: true + excluded_autobump.concat(autobumped_formulae_or_casks(CoreCaskTap.instance, casks: true)) end end @@ -132,7 +130,7 @@ 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) } + formulae_and_casks -= excluded_autobump if args.repology? && !Utils::Curl.curl_supports_tls13? begin @@ -562,9 +560,11 @@ module Homebrew 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) + if casks + Cask::CaskLoader.load(qualified_name) + else + Formulary.factory(qualified_name) + end end end end diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi index 8a7501c9f3..827cad9b54 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi @@ -18,7 +18,7 @@ class Homebrew::DevCmd::Bump::Args < Homebrew::CLI::Args # 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 + def no_autobump?; end sig { returns(T::Boolean) } def cask?; end From 3c33fa9d43b64bca951c6ba8c7124ba2b9ed7d45 Mon Sep 17 00:00:00 2001 From: botantony Date: Wed, 2 Apr 2025 20:29:50 +0200 Subject: [PATCH 3/3] dev-cmd/bump: update shell completions and man page Signed-off-by: botantony --- completions/bash/brew | 1 + completions/fish/brew.fish | 1 + completions/zsh/_brew | 3 ++- docs/Manpage.md | 4 ++++ manpages/brew.1 | 5 ++++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/completions/bash/brew b/completions/bash/brew index c57dd09cf4..b3bab548ef 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -515,6 +515,7 @@ _brew_bump() { --full-name --help --installed + --no-autobump --no-fork --no-pull-requests --open-pr diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index 5e53345443..04c8cfe414 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -406,6 +406,7 @@ __fish_brew_complete_arg 'bump' -l formula -d 'Check only formulae' __fish_brew_complete_arg 'bump' -l full-name -d 'Print formulae/casks with fully-qualified names' __fish_brew_complete_arg 'bump' -l help -d 'Show this message' __fish_brew_complete_arg 'bump' -l installed -d 'Check formulae and casks that are currently installed' +__fish_brew_complete_arg 'bump' -l no-autobump -d 'Ignore formulae/casks in autobump list (official repositories only)' __fish_brew_complete_arg 'bump' -l no-fork -d 'Don\'t try to fork the repository' __fish_brew_complete_arg 'bump' -l no-pull-requests -d 'Do not retrieve pull requests from GitHub' __fish_brew_complete_arg 'bump' -l open-pr -d 'Open a pull request for the new version if none have been opened yet' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index b250776f5d..5b36ec0f86 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -539,13 +539,14 @@ _brew_bump() { '--full-name[Print formulae/casks with fully-qualified names]' \ '--help[Show this message]' \ '(--tap --eval-all --auto)--installed[Check formulae and casks that are currently installed]' \ + '--no-autobump[Ignore formulae/casks in autobump list (official repositories only)]' \ '--no-fork[Don'\''t try to fork the repository]' \ '(--open-pr)--no-pull-requests[Do not retrieve pull requests from GitHub]' \ '(--no-pull-requests)--open-pr[Open a pull request for the new version if none have been opened yet]' \ '--quiet[Make some output more quiet]' \ '--repology[Use Repology to check for outdated packages]' \ '--start-with[Letter or word that the list of package results should alphabetically follow]' \ - '(--installed)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \ + '(--installed --no-auto)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \ '--verbose[Make some output more verbose]' \ - formula \ '(--cask)--formula[Check only formulae]' \ diff --git a/docs/Manpage.md b/docs/Manpage.md index ad1f0f591b..cc62b3741c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -2090,6 +2090,10 @@ displays whether a pull request has been opened with the URL. : Do not retrieve pull requests from GitHub. +`--no-autobump` + +: Ignore formulae/casks in autobump list (official repositories only). + `--formula` : Check only formulae. diff --git a/manpages/brew.1 b/manpages/brew.1 index fdf4c98a05..2119829fcb 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1,5 +1,5 @@ .\" generated by kramdown -.TH "BREW" "1" "March 2025" "Homebrew" +.TH "BREW" "1" "April 2025" "Homebrew" .SH NAME brew \- The Missing Package Manager for macOS (or Linux) .SH "SYNOPSIS" @@ -1310,6 +1310,9 @@ Print formulae/casks with fully\-qualified names\. \fB\-\-no\-pull\-requests\fP Do not retrieve pull requests from GitHub\. .TP +\fB\-\-no\-autobump\fP +Ignore formulae/casks in autobump list (official repositories only)\. +.TP \fB\-\-formula\fP Check only formulae\. .TP