From f96290eb39b9985af01683b4d479b63338c1e4b0 Mon Sep 17 00:00:00 2001 From: Michka Popoff Date: Fri, 1 Mar 2024 09:15:43 +0000 Subject: [PATCH] bump-formula|cask-pr: do not allow to bump autobumped packages Avoids: - Bumping stuff by mistake that will get autobumped anyway - Abusing the system to get "free" commits --- Library/Homebrew/dev-cmd/bump-cask-pr.rb | 14 ++++++++++++++ Library/Homebrew/dev-cmd/bump-formula-pr.rb | 14 ++++++++++++++ Library/Homebrew/tap.rb | 1 + 3 files changed, 29 insertions(+) diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index 3654de10b283f..d2fcd366daa7b 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -89,6 +89,20 @@ def bump_cask_pr odie "This cask is not in a tap!" if cask.tap.blank? odie "This cask's tap is not a Git repository!" unless cask.tap.git? + if ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", false).blank? && + (cask.tap.core_cask_tap? && + (autobump_file_path = cask.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE) && + autobump_file_path.exist? && + autobump_file_path.readlines(chomp: true).include?(cask.token)) + odie <<~EOS + Whoops, the #{cask.token} cask has its version update + pull requests automatically opened by BrewTestBot! + We'd still love your contributions, though, so try another one + that's not in the autobump list: + #{Formatter.url("#{cask.tap.remote}/blob/master/.github/autobump.txt")} + EOS + end + new_version = BumpVersionParser.new( general: args.version, intel: args.version_intel, diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 634fa73110e28..f4acd43a8f5e3 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -112,6 +112,20 @@ def bump_formula_pr odie "This formula is not in a tap!" if formula.tap.blank? odie "This formula's tap is not a Git repository!" unless formula.tap.git? + if ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", nil).blank? && + (formula.tap.core_tap? && + (autobump_file_path = formula.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE) && + autobump_file_path.exist? && + autobump_file_path.readlines(chomp: true).include?(formula.name)) + odie <<~EOS + Whoops, the #{formula.name} formula has its version update + pull requests automatically opened by BrewTestBot! + We'd still love your contributions, though, so try another one + that's not in the autobump list: + #{Formatter.url("#{formula.tap.remote}/blob/master/.github/autobump.txt")} + EOS + end + formula_spec = formula.stable odie "#{formula}: no stable specification found!" if formula_spec.blank? diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 5bad532b3bffd..26d4d1bcf5fb0 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -21,6 +21,7 @@ class Tap HOMEBREW_TAP_CASK_RENAMES_FILE = "cask_renames.json" HOMEBREW_TAP_FORMULA_RENAMES_FILE = "formula_renames.json" HOMEBREW_TAP_MIGRATIONS_FILE = "tap_migrations.json" + HOMEBREW_TAP_AUTOBUMP_FILE = ".github/autobump.txt" HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR = "audit_exceptions" HOMEBREW_TAP_STYLE_EXCEPTIONS_DIR = "style_exceptions" HOMEBREW_TAP_PYPI_FORMULA_MAPPINGS = "pypi_formula_mappings.json"