From 38f00671c4c5d83f749bfe2cbb9bdbac4e89ccd0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 14 Aug 2023 19:28:56 +0100 Subject: [PATCH] cmd/update-report: correctly handle added/deleted formulae/casks. If a formulae or cask is marked as both added and deleted, we've just incorrectly detected it. Remove it from the report. This can happen when a formula or cask is moved around in the repository e.g. with sharding. --- Library/Homebrew/cmd/update-report.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index fd6468788c..0f970d442e 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -566,6 +566,17 @@ class Reporter @report[:R] = renamed_formulae.to_a end + # If any formulae/casks are marked as added and deleted, remove them from + # the report as we've not detected things correctly. + if (added_and_deleted_formulae = (@report[:A] & @report[:D]).presence) + @report[:A] -= added_and_deleted_formulae + @report[:D] -= added_and_deleted_formulae + end + if (added_and_deleted_casks = (@report[:AC] & @report[:DC]).presence) + @report[:AC] -= added_and_deleted_casks + @report[:DC] -= added_and_deleted_casks + end + @report end