brew/Library/Homebrew/bundle/tap_installer.rb
Mike McQuaid b32296a7e0
bundle/tap_installer: add force flag for official taps for developers.
This avoids a `homebrew/core` in a `Brewfile` failing for Homebrew
developers who probably want it.
2025-08-28 16:41:50 +01:00

47 lines
1.3 KiB
Ruby

# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true
module Homebrew
module Bundle
module TapInstaller
def self.preinstall!(name, verbose: false, **_options)
if installed_taps.include? name
puts "Skipping install of #{name} tap. It is already installed." if verbose
return false
end
true
end
def self.install!(name, preinstall: true, verbose: false, force: false, **options)
return true unless preinstall
puts "Installing #{name} tap. It is not currently installed." if verbose
args = []
official_tap = name.downcase.start_with? "homebrew/"
args << "--force" if force || (official_tap && Homebrew::EnvConfig.developer?)
success = if options[:clone_target]
Bundle.brew("tap", name, options[:clone_target], *args, verbose:)
else
Bundle.brew("tap", name, *args, verbose:)
end
unless success
require "bundle/skipper"
Homebrew::Bundle::Skipper.tap_failed!(name)
return false
end
installed_taps << name
true
end
def self.installed_taps
require "bundle/tap_dumper"
@installed_taps ||= Homebrew::Bundle::TapDumper.tap_names
end
end
end
end