Merge pull request #11060 from Bo98/bottle-keep-old

dev-cmd/bottle: don't fail on --keep-old with unchanged values
This commit is contained in:
Bo Anderson 2021-04-07 20:47:17 +01:00 committed by GitHub
commit 1777a03aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -679,8 +679,10 @@ module Homebrew
old_hexdigest = old_checksum_hash[:checksum].hexdigest
old_cellar = old_checksum_hash[:cellar]
new_value = new_bottle_hash.dig("tags", tag.to_s)
if new_value.present?
mismatches << "sha256 => #{tag}"
if new_value.present? && new_value["sha256"] != old_hexdigest
mismatches << "sha256 #{tag}: old: #{old_hexdigest.inspect}, new: #{new_value["sha256"].inspect}"
elsif new_value.present? && new_value["cellar"] != old_cellar.to_s
mismatches << "cellar #{tag}: old: #{old_cellar.to_s.inspect}, new: #{new_value["cellar"].inspect}"
else
checksums << { cellar: old_cellar, tag => old_hexdigest }
end

View File

@ -580,13 +580,15 @@ describe "brew bottle" do
it "checks for conflicting checksums" do
old_spec = BottleSpecification.new
old_spec.sha256(catalina: "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e")
old_catalina_sha256 = "109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e"
old_spec.sha256(catalina: old_catalina_sha256)
old_spec.sha256(mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f")
new_hash = { "tags" => { "catalina" => "ec6d7f08412468f28dee2be17ad8cd8b883b16b34329efcecce019b8c9736428" } }
new_catalina_sha256 = "ec6d7f08412468f28dee2be17ad8cd8b883b16b34329efcecce019b8c9736428"
new_hash = { "tags" => { "catalina" => { "sha256" => new_catalina_sha256 } } }
expected_checksum_hash = { mojave: "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f" }
expected_checksum_hash[:cellar] = Homebrew::DEFAULT_CELLAR
expect(homebrew.merge_bottle_spec([:sha256], old_spec, new_hash)).to eq [
["sha256 => catalina"],
["sha256 catalina: old: #{old_catalina_sha256.inspect}, new: #{new_catalina_sha256.inspect}"],
[expected_checksum_hash],
]
end