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.
This commit is contained in:
Issy Long 2021-06-08 23:43:14 +01:00
parent 76cda750d5
commit 155feba8e0
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
3 changed files with 6 additions and 4 deletions

View File

@ -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}

View File

@ -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 }

View File

@ -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