Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/--cache: avoid exception on missing HEAD #18422

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading