Rename formula_support to keg_only reason, refactor slightly

This commit is contained in:
Douglas Eichelberger 2025-08-24 14:55:57 -07:00
parent 566290dcbc
commit 6a25de5daf
No known key found for this signature in database
GPG Key ID: F90193CBD547EB81
8 changed files with 13 additions and 13 deletions

View File

@ -1,4 +0,0 @@
# typed: strict
# frozen_string_literal: true
require "extend/os/mac/formula_support" if OS.mac?

View File

@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true
require "extend/os/mac/keg_only_reason" if OS.mac?

View File

@ -4,7 +4,7 @@
require "autobump_constants"
require "cache_store"
require "did_you_mean"
require "formula_support"
require "keg_only_reason"
require "lock_file"
require "formula_pin"
require "hardware"
@ -88,6 +88,9 @@ class Formula
abstract!
# Used to track formulae that cannot be installed at the same time.
FormulaConflict = Struct.new(:name, :reason)
SUPPORTED_NETWORK_ACCESS_PHASES = [:build, :test, :postinstall].freeze
private_constant :SUPPORTED_NETWORK_ACCESS_PHASES
DEFAULT_NETWORK_ACCESS_ALLOWED = true

View File

@ -1,9 +1,6 @@
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true
# Used to track formulae that cannot be installed at the same time.
FormulaConflict = Struct.new(:name, :reason)
# Used to annotate formulae that duplicate macOS-provided software
# or cause conflicts when linked in.
class KegOnlyReason
@ -33,7 +30,7 @@ class KegOnlyReason
sig { returns(T::Boolean) }
def applicable?
# macOS reasons aren't applicable on other OSs
# (see extend/os/mac/formula_support for override on macOS)
# (see extend/os/mac/keg_only_reason for override on macOS)
!by_macos?
end
@ -74,4 +71,4 @@ class KegOnlyReason
end
end
require "extend/os/formula_support"
require "extend/os/keg_only_reason"

View File

@ -137,7 +137,7 @@ RSpec.describe Homebrew::Bundle::Commands::Exec do
plist_name: "homebrew.mxcl.nginx",
service_name: "nginx",
versioned_formulae_names: [],
conflicts: [instance_double(FormulaConflict, name: "httpd")],
conflicts: [instance_double(Formula::FormulaConflict, name: "httpd")],
keg_only?: false,
)
end

View File

@ -176,7 +176,7 @@ RSpec.describe "Exception" do
subject(:error) { described_class.new(formula, [conflict]) }
let(:formula) { instance_double(Formula, full_name: "foo/qux") }
let(:conflict) { instance_double(FormulaConflict, name: "bar", reason: "I decided to") }
let(:conflict) { instance_double(Formula::FormulaConflict, name: "bar", reason: "I decided to") }
it(:to_s) { expect(error.to_s).to match(/Please `brew unlink bar` before continuing\./) }
end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require "formula_support"
require "keg_only_reason"
RSpec.describe KegOnlyReason do
describe "#to_s" do