Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-cmd/bump: skip autobump formulae & casks #16833

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions Library/Homebrew/dev-cmd/bump-cask-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,13 @@ 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
odie <<~EOS unless cask.tap.allow_bump?(cask.token)
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

new_version = BumpVersionParser.new(
general: args.version,
Expand Down
20 changes: 7 additions & 13 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,13 @@ 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
odie <<~EOS unless formula.tap.allow_bump?(formula.name)
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

formula_spec = formula.stable
odie "#{formula}: no stable specification found!" if formula_spec.blank?
Expand Down
12 changes: 8 additions & 4 deletions Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,20 @@ def handle_api_response(args)
}
def skip_ineligible_formulae(formula_or_cask)
if formula_or_cask.is_a?(Formula)
return false if !formula_or_cask.disabled? && !formula_or_cask.head_only?

skip = formula_or_cask.disabled? || formula_or_cask.head_only?
name = formula_or_cask.name
text = "Formula is #{formula_or_cask.disabled? ? "disabled" : "HEAD-only"}.\n"
else
return false unless formula_or_cask.disabled?

skip = formula_or_cask.disabled?
name = formula_or_cask.token
text = "Cask is disabled.\n"
end
unless formula_or_cask.tap.allow_bump?(name)
skip = true
text = "#{text.split.first} is on autobump list.\n"
end
return false unless skip

ohai name
puts text
true
Expand Down
25 changes: 25 additions & 0 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,22 @@ def tap_migrations
end
end

# Array with autobump names
sig { returns(T::Array[String]) }
def autobump
@autobump ||= if (autobump_file = path/HOMEBREW_TAP_AUTOBUMP_FILE).file?
autobump_file.readlines(chomp: true)
else
[]
end
end

# Whether this {Tap} allows running bump commands on the given {Formula} or {Cask}.
sig { params(formula_or_cask_name: String).returns(T::Boolean) }
def allow_bump?(formula_or_cask_name)
ENV["HOMEBREW_TEST_BOT_AUTOBUMP"].present? || !official? || autobump.exclude?(formula_or_cask_name)
cho-m marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe just read GITHUB_ACTOR or similar here to avoid having to carry around an extra environment variable in our workflows.

end

# Hash with audit exceptions
sig { returns(Hash) }
def audit_exceptions
Expand Down Expand Up @@ -1161,6 +1177,15 @@ def tap_migrations
end
end

# @private
sig { returns(T::Array[String]) }
def autobump
@autobump ||= begin
ensure_installed!
super
end
end

# @private
sig { returns(Hash) }
def audit_exceptions
Expand Down
Loading