cmd/--cache: avoid exception on missing HEAD

Also add cask to description
This commit is contained in:
Michael Cho 2024-09-26 09:48:29 -04:00
parent 5ef30ad415
commit b1de5a22d2
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
3 changed files with 9 additions and 5 deletions

View File

@ -17,7 +17,7 @@ module Homebrew
description <<~EOS description <<~EOS
Display Homebrew's download cache. See also `HOMEBREW_CACHE`. 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.
EOS EOS
flag "--os=", flag "--os=",
description: "Show cache file for the given operating system. " \ description: "Show cache file for the given operating system. " \
@ -113,7 +113,11 @@ module Homebrew
puts bottle.cached_download puts bottle.cached_download
elsif args.HEAD? 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 else
puts formula.cached_download puts formula.cached_download
end end

View File

@ -1494,8 +1494,8 @@ dependency for their stable builds.
Display Homebrew's download cache. See also `HOMEBREW_CACHE`. Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
If *`formula`* is provided, display the file or directory used to cache If a *`formula`* or *`cask`* is provided, display the file or directory used to
*`formula`*. cache it.
`--os` `--os`

View File

@ -938,7 +938,7 @@ Include only casks\.
.SS "\fB\-\-cache\fP \fR[\fIoptions\fP] \fR[\fIformula\fP|\fIcask\fP \.\.\.]" .SS "\fB\-\-cache\fP \fR[\fIoptions\fP] \fR[\fIformula\fP|\fIcask\fP \.\.\.]"
Display Homebrew\[u2019]s download cache\. See also \fBHOMEBREW_CACHE\fP\&\. Display Homebrew\[u2019]s download cache\. See also \fBHOMEBREW_CACHE\fP\&\.
.P .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 .TP
\fB\-\-os\fP \fB\-\-os\fP
Show cache file for the given operating system\. (Pass \fBall\fP to show cache files for all operating systems\.) Show cache file for the given operating system\. (Pass \fBall\fP to show cache files for all operating systems\.)