Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ def audit_no_autobump
return if cask.autobump?
return unless new_cask?

error = SharedAudits.no_autobump_new_package_message(cask.no_autobump_message)
error = SharedAudits.no_autobump_audit_message(cask.no_autobump_message, new_package: true)
add_error error if error
end

Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4517,6 +4517,12 @@ def no_autobump!(because:)
raise ArgumentError, "'because' argument should use valid symbol or a string!"
end

# TODO: deprecate `no_autobump! because: :requires_manual_review` once we have no formulae in core
# that use this stanza. Do not forget to remove related audit from `utils/shared_audits.rb`
# and key from `autobump_constants.rb`!
#
# odeprecated "no_autobump! because: :requires_manual_review" if because == :requires_manual_review

@no_autobump_defined = T.let(true, T.nilable(T::Boolean))
@no_autobump_message = T.let(because, T.nilable(T.any(String, Symbol)))
@autobump = T.let(false, T.nilable(T::Boolean))
Expand Down
23 changes: 20 additions & 3 deletions Library/Homebrew/formula_auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,27 @@ def audit_deprecate_disable
def audit_no_autobump
return if formula.autobump?

return unless @new_formula_inclusive
if @new_formula_inclusive
error = SharedAudits.no_autobump_audit_message(formula.no_autobump_message, new_package: true)
new_formula_problem error if error
return
end

error = SharedAudits.no_autobump_new_package_message(formula.no_autobump_message)
new_formula_problem error if error
return unless @git
return unless formula.tap
return unless formula.tap.git?
return if formula.stable.blank?

current_version = formula.stable.version

_, origin_head_version_info = committed_version_info
return if origin_head_version_info.empty?

# Check `no_autobump!` if on version change
return if current_version == origin_head_version_info[:version]

error = SharedAudits.no_autobump_audit_message(formula.no_autobump_message)
problem error if error
end

def quote_dep(dep)
Expand Down
83 changes: 66 additions & 17 deletions Library/Homebrew/test/formula_auditor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1728,32 +1728,81 @@ class Foo < Formula
end

describe "#audit_no_autobump" do
it "warns when autobump exclusion reason is not suitable for new formula" do
fa = formula_auditor "foo", <<~RUBY, new_formula: true
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
subject(:no_autobump_audit) do
fa = described_class.new(Formulary.factory(formula_path), git: true)
fa.audit_no_autobump
fa.problems.first&.fetch(:message)
end

before do
origin_formula_path.dirname.mkpath
origin_formula_path.write <<~RUBY
class Foo#{foo_version} < Formula
url "https://brew.sh/foo-1.0.tar.gz"
sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"

no_autobump! because: :requires_manual_review
no_autobump! because: "no_autobump_placeholder"
end
RUBY

fa.audit_no_autobump
expect(fa.new_formula_problems.first[:message])
.to match("`:requires_manual_review` is a temporary reason intended for existing packages, " \
"use a different reason instead.")
origin_tap_path.mkpath
origin_tap_path.cd do
system "git", "init"
system "git", "add", "--all"
system "git", "commit", "-m", "init"
end

tap_path.mkpath
tap_path.cd do
system "git", "clone", origin_tap_path, "."
end
end

it "does not warn when autobump exclusion reason is allowed" do
fa = formula_auditor "foo", <<~RUBY, new_formula: true
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
describe "no_autobump" do
context "when version is changed" do
before do
formula_gsub "foo-1.0.tar.gz", "foo-1.1.tar.gz"
formula_gsub '"no_autobump_placeholder"', ":requires_manual_review"
end

no_autobump! because: "foo bar"
it do
expect(no_autobump_audit).to match("`:requires_manual_review` is a temporary to-be deprecated reason, " \
"change or remove autobump exclusion reason.")
end
RUBY
end

fa.audit_no_autobump
expect(fa.new_formula_problems).to be_empty
context "when version is not changed" do
before { formula_gsub '"no_autobump_placeholder"', ":requires_manual_review" }

it { is_expected.to be_nil }
end

context "when version is changed but the autobump exclusion reason is not `:requires_manual_review`" do
before { formula_gsub "foo-1.0.tar.gz", "foo-1.1.tar.gz" }

it { is_expected.to be_nil }
end

context "when autobump exclusion reason is not `:requires_manual_review`" do
it { is_expected.to be_nil }
end

context "when a new formula is created" do
it "warns when autobump exclusion reason is not suitable for new formula" do
fa = formula_auditor "foo", <<~RUBY, new_formula: true
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"

no_autobump! because: :requires_manual_review
end
RUBY

fa.audit_no_autobump
expect(fa.new_formula_problems.first[:message])
.to match("`:requires_manual_review` is a temporary to-be deprecated reason, " \
"use a different reason instead.")
end
end
end
end
end
8 changes: 5 additions & 3 deletions Library/Homebrew/utils/shared_audits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ def self.check_deprecate_disable_reason(formula_or_cask)
"#{reason} is not a valid deprecate! or disable! reason" unless reasons.include?(reason)
end

sig { params(message: T.any(String, Symbol)).returns(T.nilable(String)) }
def self.no_autobump_new_package_message(message)
sig { params(message: T.any(String, Symbol), new_package: T::Boolean).returns(T.nilable(String)) }
def self.no_autobump_audit_message(message, new_package: false)
return if message.is_a?(String) || message != :requires_manual_review

"`:requires_manual_review` is a temporary reason intended for existing packages, use a different reason instead."
msg = new_package ? "use a different reason instead" : "change or remove autobump exclusion reason"

"`:requires_manual_review` is a temporary to-be deprecated reason, #{msg}."
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The warning text reads awkwardly ("temporary to-be deprecated reason"). Consider rephrasing to standard grammar (e.g., "temporary reason slated for deprecation") so the audit output is clear and consistent.

Suggested change
"`:requires_manual_review` is a temporary to-be deprecated reason, #{msg}."
"`:requires_manual_review` is a temporary reason slated for deprecation, #{msg}."

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a #odeprecated somewhere to be uncommented when we're ready to deprecate for the next major/minor release?

end
end
Loading