bottle: further improve --keep-old mismatching.
- Make the code more similar between `bottle` and `bottle --merge`. - Also output the mismatched values when using `--merge`.
This commit is contained in:
parent
cfc930011d
commit
ea5da9b592
@ -289,22 +289,22 @@ module Homebrew
|
|||||||
|
|
||||||
old_spec = f.bottle_specification
|
old_spec = f.bottle_specification
|
||||||
if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
|
if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
|
||||||
bad_fields = [:root_url, :prefix, :cellar, :rebuild].select do |field|
|
mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |field|
|
||||||
old_spec.send(field) != bottle.send(field)
|
old_spec.send(field) != bottle.send(field)
|
||||||
end
|
end
|
||||||
bad_fields.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
|
mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
|
||||||
unless bad_fields.empty?
|
unless mismatches.empty?
|
||||||
bottle_path.unlink if bottle_path.exist?
|
bottle_path.unlink if bottle_path.exist?
|
||||||
|
|
||||||
bad_changes = bad_fields.map do |field|
|
mismatches.map! do |field|
|
||||||
old_value = old_spec.send(field).inspect
|
old_value = old_spec.send(field).inspect
|
||||||
bottle_value = bottle.send(field).inspect
|
value = bottle.send(field).inspect
|
||||||
"#{field}: old: #{old_value}, new: #{bottle_value}"
|
"#{field}: old: #{old_value}, new: #{value}"
|
||||||
end
|
end
|
||||||
|
|
||||||
odie <<-EOS.undent
|
odie <<-EOS.undent
|
||||||
--keep-old was passed but there are changes in:
|
--keep-old was passed but there are changes in:
|
||||||
#{bad_changes.join("\n")}
|
#{mismatches.join("\n")}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -383,11 +383,11 @@ module Homebrew
|
|||||||
bottle_block_contents.lines.each do |line|
|
bottle_block_contents.lines.each do |line|
|
||||||
line = line.strip
|
line = line.strip
|
||||||
next if line.empty?
|
next if line.empty?
|
||||||
key, value, _, tag = line.split " ", 4
|
key, value_original, _, tag = line.split " ", 4
|
||||||
valid_key = %w[root_url prefix cellar rebuild sha1 sha256].include? key
|
valid_key = %w[root_url prefix cellar rebuild sha1 sha256].include? key
|
||||||
next unless valid_key
|
next unless valid_key
|
||||||
|
|
||||||
value = value.to_s.delete ":'\""
|
value = value_original.to_s.delete ":'\""
|
||||||
tag = tag.to_s.delete ":"
|
tag = tag.to_s.delete ":"
|
||||||
|
|
||||||
if !tag.empty?
|
if !tag.empty?
|
||||||
@ -399,11 +399,21 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
old_value = bottle_hash["bottle"][key].to_s
|
old_value_original = bottle_hash["bottle"][key]
|
||||||
|
old_value = old_value_original.to_s
|
||||||
next if key == "cellar" && old_value == "any" && value == "any_skip_relocation"
|
next if key == "cellar" && old_value == "any" && value == "any_skip_relocation"
|
||||||
mismatches << key if old_value.empty? || value != old_value
|
if old_value.empty? || value != old_value
|
||||||
|
old_value = old_value_original.inspect
|
||||||
|
value = value_original.inspect
|
||||||
|
mismatches << "#{field}: old: #{old_value}, new: #{value}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
unless mismatches.empty?
|
unless mismatches.empty?
|
||||||
|
odie <<-EOS.undent
|
||||||
|
--keep-old was passed but there are changes in:
|
||||||
|
#{mismatches.join("\n")}
|
||||||
|
EOS
|
||||||
odie "--keep-old was passed but there were changes in #{mismatches.join(", ")}!"
|
odie "--keep-old was passed but there were changes in #{mismatches.join(", ")}!"
|
||||||
end
|
end
|
||||||
output = bottle_output bottle
|
output = bottle_output bottle
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user