From c80107c8a20b3615aab2c0b13b3ade56f1006a1e Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Mon, 27 Jan 2020 19:31:10 +0100 Subject: [PATCH] bottle: prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation --- Library/Homebrew/dev-cmd/bottle.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 4c99c022a7..505b6b1675 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -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|