Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bottle: prioritize HOMEBREW_CELLAR over :any over :any_skip_relocation #6969

Merged
merged 1 commit into from Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion Library/Homebrew/dev-cmd/bottle.rb
Expand Up @@ -439,7 +439,27 @@ def merge
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
dawidd6 marked this conversation as resolved.
Show resolved Hide resolved
else
second
end
else
second
end
end
end

bottles_hash.each do |formula_name, bottle_hash|
Expand Down