From b1de5a22d2742fc659ec8cae6c0a2049d0b50d94 Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Thu, 26 Sep 2024 09:48:29 -0400 Subject: [PATCH] cmd/--cache: avoid exception on missing HEAD Also add cask to description --- Library/Homebrew/cmd/--cache.rb | 8 ++++++-- docs/Manpage.md | 4 ++-- manpages/brew.1 | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/--cache.rb b/Library/Homebrew/cmd/--cache.rb index fef83fafadb31..79137eb298849 100644 --- a/Library/Homebrew/cmd/--cache.rb +++ b/Library/Homebrew/cmd/--cache.rb @@ -17,7 +17,7 @@ def self.command_name = "--cache" description <<~EOS Display Homebrew's download cache. See also `HOMEBREW_CACHE`. - If is provided, display the file or directory used to cache . + If a or is provided, display the file or directory used to cache it. EOS flag "--os=", description: "Show cache file for the given operating system. " \ @@ -113,7 +113,11 @@ def print_formula_cache(formula, os:, arch:) puts bottle.cached_download elsif args.HEAD? - puts T.must(formula.head).cached_download + if (head = formula.head) + puts head.cached_download + else + opoo "No head is defined for #{formula.full_name}." + end else puts formula.cached_download end diff --git a/docs/Manpage.md b/docs/Manpage.md index f510f84d8545f..99ca5e54d2828 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1494,8 +1494,8 @@ dependency for their stable builds. Display Homebrew's download cache. See also `HOMEBREW_CACHE`. -If *`formula`* is provided, display the file or directory used to cache -*`formula`*. +If a *`formula`* or *`cask`* is provided, display the file or directory used to +cache it. `--os` diff --git a/manpages/brew.1 b/manpages/brew.1 index 99f75ff08d3cc..b75bd29081282 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -938,7 +938,7 @@ Include only casks\. .SS "\fB\-\-cache\fP \fR[\fIoptions\fP] \fR[\fIformula\fP|\fIcask\fP \.\.\.]" Display Homebrew\[u2019]s download cache\. See also \fBHOMEBREW_CACHE\fP\&\. .P -If \fIformula\fP is provided, display the file or directory used to cache \fIformula\fP\&\. +If a \fIformula\fP or \fIcask\fP is provided, display the file or directory used to cache it\. .TP \fB\-\-os\fP Show cache file for the given operating system\. (Pass \fBall\fP to show cache files for all operating systems\.)