feat: Install an unlinked formula via brew install if --overwrite is passed

If the intention is to overwrite any existing links, then `brew install` should go on to install over an unlinked formula
This commit is contained in:
Bob Lail 2024-10-08 11:19:58 -07:00 committed by Bob Lail
parent 3291ad4fc7
commit a5db113d91
2 changed files with 4 additions and 2 deletions

View File

@ -289,6 +289,7 @@ module Homebrew
only_dependencies: args.only_dependencies?, only_dependencies: args.only_dependencies?,
force: args.force?, force: args.force?,
quiet: args.quiet?, quiet: args.quiet?,
overwrite: args.overwrite?,
) )
end end

View File

@ -60,7 +60,8 @@ module Homebrew
fetch_head: false, fetch_head: false,
only_dependencies: false, only_dependencies: false,
force: false, force: false,
quiet: false quiet: false,
overwrite: false
) )
# head-only without --HEAD is an error # head-only without --HEAD is an error
if !head && formula.stable.nil? if !head && formula.stable.nil?
@ -132,7 +133,7 @@ module Homebrew
The currently linked version is: #{formula.linked_version} The currently linked version is: #{formula.linked_version}
EOS EOS
end end
elsif only_dependencies elsif only_dependencies || (!formula.linked? && overwrite)
msg = nil msg = nil
return true return true
elsif !formula.linked? || formula.keg_only? elsif !formula.linked? || formula.keg_only?