Use tap#autobump

This commit is contained in:
Carlo Cabrera 2024-09-02 22:10:05 +08:00
parent 07d04dd348
commit e6dd9fbd9c
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -31,7 +31,7 @@ module Homebrew
switch "--no-pull-requests",
description: "Do not retrieve pull requests from GitHub."
switch "--auto",
description: "Read the list of formulae/casks from .github/autobump.txt.",
description: "Read the list of formulae/casks from the tap autobump list.",
hidden: true
switch "--formula", "--formulae",
description: "Check only formulae."
@ -69,15 +69,17 @@ module Homebrew
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
formulae_and_casks = if args.auto?
tap_arg = args.tap
raise UsageError, "`--tap=` must be passed with `--auto`." if tap_arg.blank?
raise UsageError, "`--formula` or `--cask` must be passed with `--auto`." if !args.formula? && !args.cask?
tap = Tap.fetch(tap_arg)
autobump_list = tap.path/".github/autobump.txt"
raise UsageError, "No autobump list at .github/autobump.txt found." unless autobump_list.exist?
tap_arg = args.tap
raise UsageError, "`--tap=` must be passed with `--auto`." if tap_arg.blank?
autobump_list.readlines(chomp: true).map do |name|
tap = Tap.fetch(tap_arg)
autobump_list = tap.autobump
what = args.cask? ? "casks" : "formulae"
raise UsageError, "No autobumped #{what} found." if autobump_list.blank?
autobump_list.map do |name|
qualified_name = "#{tap.name}/#{name}"
next Cask::CaskLoader.load(qualified_name) if args.cask?
@ -85,7 +87,7 @@ module Homebrew
end
elsif args.tap
tap = Tap.fetch(T.must(args.tap))
raise UsageError, "`--tap` cannot be used with official taps." if tap.official?
raise UsageError, "`--tap` without `--auto` cannot be used with official taps." if tap.official?
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }