From 1bb651469f97e899761f04946dacd65a48fb0a63 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 7 Apr 2021 19:56:31 +0100 Subject: [PATCH] dev-cmd/bottle: don't fail on --keep-old with unchanged values --- Library/Homebrew/dev-cmd/bottle.rb | 6 ++++-- Library/Homebrew/test/dev-cmd/bottle_spec.rb | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 8ebc1ae981..3a3f771c70 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -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 diff --git a/Library/Homebrew/test/dev-cmd/bottle_spec.rb b/Library/Homebrew/test/dev-cmd/bottle_spec.rb index f349b40952..39f440180f 100644 --- a/Library/Homebrew/test/dev-cmd/bottle_spec.rb +++ b/Library/Homebrew/test/dev-cmd/bottle_spec.rb @@ -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