From 155feba8e057e8dc66661ad6fe8021a30a5c4e93 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 8 Jun 2021 23:43:14 +0100 Subject: [PATCH] cask/installer: Add Cask caveats to the end-of-operation summary - Both formulae and casks can have caveats, but only formulae caveats were shown at the end of a bulk install/upgrade/reinstall operation via `Homebrew.messages.record_caveats`. This fixes that to show Cask caveats too, for consistency (scrolling up all of the multi-formulae-and-casks output to see caveats is time-consuming and users might miss them). - In doing this I had to change how `Messages#record_caveats` works since the cask name is just a string, not an object. --- Library/Homebrew/cask/installer.rb | 2 ++ Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/messages.rb | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index e6241fb3ea..f9faefe9cd 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -56,6 +56,8 @@ module Cask caveats = cask.caveats return if caveats.empty? + Homebrew.messages.record_caveats(cask.token, caveats) + <<~EOS #{ohai_title "Caveats"} #{caveats} diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 1d9193dcab..dc7e1bee35 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -769,7 +769,7 @@ class FormulaInstaller @show_summary_heading = true ohai "Caveats", caveats.to_s - Homebrew.messages.record_caveats(formula, caveats) + Homebrew.messages.record_caveats(formula.name, caveats) end sig { void } diff --git a/Library/Homebrew/messages.rb b/Library/Homebrew/messages.rb index 0e6b3164f2..6cc2cbcad6 100644 --- a/Library/Homebrew/messages.rb +++ b/Library/Homebrew/messages.rb @@ -15,8 +15,8 @@ class Messages @install_times = [] end - def record_caveats(f, caveats) - @caveats.push(formula: f.name, caveats: caveats) + def record_caveats(package, caveats) + @caveats.push(package: package, caveats: caveats) end def formula_installed(f, elapsed_time) @@ -36,7 +36,7 @@ class Messages oh1 "Caveats" @caveats.each do |c| - ohai c[:formula], c[:caveats] + ohai c[:package], c[:caveats] end end