Merge pull request #6969 from dawidd6/bottle-cellar-priority

bottle: prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation
This commit is contained in:
Mike McQuaid 2020-02-11 12:31:09 +00:00 committed by GitHub
commit dca717e699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -439,7 +439,27 @@ module Homebrew
raise UsageError, "--merge requires a JSON file path argument" if Homebrew.args.named.blank?
bottles_hash = Homebrew.args.named.reduce({}) do |hash, json_file|
hash.deep_merge(JSON.parse(IO.read(json_file)))
hash.deep_merge(JSON.parse(IO.read(json_file))) do |key, first, second|
if key == "cellar"
# Prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation
cellars = [first, second]
if cellars.include?(HOMEBREW_CELLAR)
HOMEBREW_CELLAR
elsif first.start_with?("/")
first
elsif second.start_with?("/")
second
elsif cellars.include?(:any)
:any
elsif cellars.include?(:any_skip_relocation)
:any_skip_relocation
else
second
end
else
second
end
end
end
bottles_hash.each do |formula_name, bottle_hash|