Skip to content

Commit

Permalink
bump-formula|cask-pr: do not allow to bump autobumped packages
Browse files Browse the repository at this point in the history
Avoids:
- Bumping stuff by mistake that will get autobumped anyway
- Abusing the system to get "free" commits
  • Loading branch information
iMichka committed Feb 27, 2024
1 parent 973a352 commit d08c0a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Library/Homebrew/dev-cmd/bump-cask-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ 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?

autobump_file_path = cask.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE
if cask.tap.core_cask_tap? &&
autobump_file_path.exist? &&
File.readlines(autobump_file_path, chomp: true).include?(cask.name.first.downcase)
odie <<~EOS
Whoops, the #{cask.name.first.downcase} 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,
Expand Down
15 changes: 15 additions & 0 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ 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?

puts formula.tap.remote

autobump_file_path = formula.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE
if formula.tap.core_tap? &&
autobump_file_path.exist? &&
File.readlines(autobump_file_path, 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?

Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d08c0a8

Please sign in to comment.