bottle/test-bot: deep merge bottle JSON hashes.

This commit is contained in:
Mike McQuaid 2016-05-28 20:09:49 +01:00
parent 28d99940de
commit 7829af7508
4 changed files with 13 additions and 2 deletions

View File

@ -336,7 +336,7 @@ module Homebrew
write = ARGV.include? "--write"
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
hash.merge! Utils::JSON.load(IO.read(json_file))
deep_merge_hashes hash, Utils::JSON.load(IO.read(json_file))
end
bottles_hash.each do |formula_name, bottle_hash|

View File

@ -821,7 +821,7 @@ module Homebrew
formula_packaged = {}
bottles_hash = json_files.reduce({}) do |hash, json_file|
hash.merge! Utils::JSON.load(IO.read(json_file))
deep_merge_hashes hash, Utils::JSON.load(IO.read(json_file))
end
bottles_hash.each do |formula_name, bottle_hash|

View File

@ -1,5 +1,6 @@
require "pathname"
require "exceptions"
require "utils/hash"
require "utils/json"
require "utils/inreplace"
require "utils/popen"

View File

@ -0,0 +1,10 @@
def deep_merge_hashes(hash1, hash2)
merger = proc do |key, v1, v2|
if Hash === v1 && Hash === v2
v1.merge v2, &merger
else
v2
end
end
hash1.merge hash2, &merger
end