Skip to content

Commit

Permalink
Merge pull request #18422 from Homebrew/cmd-cache-touchup
Browse files Browse the repository at this point in the history
cmd/--cache: avoid exception on missing HEAD
  • Loading branch information
MikeMcQuaid authored Sep 26, 2024
2 parents 9ce39ee + b1de5a2 commit 05cde76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Library/Homebrew/cmd/--cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.command_name = "--cache"
description <<~EOS
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
flag "--os=",
description: "Show cache file for the given operating system. " \
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -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\.)
Expand Down

0 comments on commit 05cde76

Please sign in to comment.