Skip to content

Commit

Permalink
dev-cmd/bump: add --auto flag
Browse files Browse the repository at this point in the history
This will read from the tap's `.github/autobump.txt` when provided.

See discussion at Homebrew/homebrew-core#183126.
  • Loading branch information
carlocab authored and dduugg committed Sep 11, 2024
1 parent bb2d2b5 commit 5fed9b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class VersionBumpInfo < T::Struct
description: "Print formulae/casks with fully-qualified names."
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.",
hidden: true
switch "--formula", "--formulae",
description: "Check only formulae."
switch "--cask", "--casks",
Expand All @@ -52,6 +55,7 @@ class VersionBumpInfo < T::Struct
conflicts "--cask", "--formula"
conflicts "--tap=", "--installed"
conflicts "--eval-all", "--installed"
conflicts "--installed", "--auto"
conflicts "--no-pull-requests", "--open-pr"

named_args [:formula, :cask], without_api: true
Expand All @@ -64,7 +68,22 @@ def run
Homebrew.with_no_api_env do
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?

formulae_and_casks = if args.tap
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?

autobump_list.readlines(chomp: true).map do |name|
qualified_name = "#{tap.name}/#{name}"
next Cask::CaskLoader.load(qualified_name) if args.cask?

Formulary.factory(qualified_name)
end
elsif args.tap
tap = Tap.fetch(T.must(args.tap))
raise UsageError, "`--tap` cannot be used with official taps." if tap.official?

Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/bump.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fed9b2

Please sign in to comment.