Skip to content

list.sh: only show headings when there are items to show#22123

Merged
ZhongRuoyu merged 2 commits intomainfrom
brew-list-headings
May 3, 2026
Merged

list.sh: only show headings when there are items to show#22123
ZhongRuoyu merged 2 commits intomainfrom
brew-list-headings

Conversation

@ZhongRuoyu
Copy link
Copy Markdown
Member

If there are no formulae or casks to show, then don't show the "Formulae" or "Casks" headings. This used to be the case when there was only the Ruby implementation, and continues to be the case when the Ruby implementation is used 1, so we should maintain the consistency.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

Footnotes

  1. https://github.com/Homebrew/brew/blob/4a95077682ae5f342cf60ff181ebbcfb03d49117/Library/Homebrew/cmd/list.rb#L162-L170

Copilot AI review requested due to automatic review settings May 2, 2026 16:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the fast-path brew list shell implementation (list.sh) to better match the Ruby implementation by only printing section headings when there are items to display.

Changes:

  • Move the “Formulae” heading to only print when the formula list output is non-empty.
  • Move the “Casks” heading to only print when the cask list output is non-empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/list.sh
@ZhongRuoyu ZhongRuoyu force-pushed the brew-list-headings branch 2 times, most recently from a46f556 to 27a2654 Compare May 2, 2026 16:24
If there are no formulae or casks to show, then don't show the
"Formulae" or "Casks" headings. This used to be the case when there was
only the Ruby implementation, and continues to be the case when the Ruby
implementation is used [^1], so we should maintain the consistency.

[^1]: https://github.com/Homebrew/brew/blob/4a95077682ae5f342cf60ff181ebbcfb03d49117/Library/Homebrew/cmd/list.rb#L162-L170
@ZhongRuoyu ZhongRuoyu force-pushed the brew-list-headings branch from 27a2654 to 3bda513 Compare May 2, 2026 16:24
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@ZhongRuoyu ZhongRuoyu enabled auto-merge May 3, 2026 05:21
@ZhongRuoyu ZhongRuoyu added this pull request to the merge queue May 3, 2026
Merged via the queue into main with commit 44a81c8 May 3, 2026
36 checks passed
@ZhongRuoyu ZhongRuoyu deleted the brew-list-headings branch May 3, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants