Skip to content

Add list versions JSON#22360

Merged
MikeMcQuaid merged 1 commit into
mainfrom
list-versions-json-fast-path
May 21, 2026
Merged

Add list versions JSON#22360
MikeMcQuaid merged 1 commit into
mainfrom
list-versions-json-fast-path

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

  • Avoid Ruby startup for inventory-only JSON output.
  • Emit formulae and casks from fast filesystem state via jq.
  • Include nullable linked, opt-linked and pinned versions.
  • Source list.sh in tests to avoid checkout Cellar state.
  • Document --json for manpages while Ruby fails if reached.
  • Cover combined, filtered, empty and missing-jq cases.

  • 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.

OpenAI Codex 5.5 xhigh with local review and testing.


Copilot AI review requested due to automatic review settings May 20, 2026 19:00
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

This PR adds a new fast-path JSON output mode for brew list --versions --json, aiming to avoid Ruby startup by emitting installed formula/cask inventory directly from filesystem state and formatting via jq.

Changes:

  • Implement brew list --versions --json in Library/Homebrew/list.sh, producing JSON for formulae/casks including linked/opt-linked/pinned versions.
  • Add --json flag plumbing/documentation across Ruby CLI help, manpages, docs, and shell completions.
  • Add integration tests covering combined output, filtering, empty output, missing jq, and Ruby fallback failure.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
manpages/brew.1 Documents brew list --json in the manpage.
docs/Manpage.md Documents brew list --json in the docs manpage.
Library/Homebrew/list.sh Implements the fast Bash JSON inventory output using jq.
Library/Homebrew/cmd/list.rb Adds --json switch and blocks Ruby execution if reached.
Library/Homebrew/test/cmd/list_spec.rb Adds test coverage for the new JSON output behavior and error cases.
Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi Adds Sorbet RBI for json? args helper.
completions/zsh/_brew Adds --json completion for brew list.
completions/fish/brew.fish Adds --json completion for brew list.
completions/bash/brew Adds --json completion for brew list.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/list.rbi: Language not supported

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

Comment thread Library/Homebrew/list.sh Outdated
Comment thread Library/Homebrew/list.sh
Comment thread Library/Homebrew/cmd/list.rb Outdated
Comment thread manpages/brew.1 Outdated
Comment thread docs/Manpage.md Outdated
Comment thread Library/Homebrew/cmd/list.rb Outdated
Comment thread Library/Homebrew/list.sh
- Avoid Ruby startup for inventory-only JSON output.
- Emit formulae and casks from fast filesystem state via `jq`.
- Include nullable linked, opt-linked and pinned versions.
- Reject invalid JSON option mixes in Bash before Ruby starts.
- Source `list.sh` in tests to avoid checkout `Cellar` state.
- Document `--json` for manpages while Ruby fails if reached.
- Cover combined, filtered, empty and missing-`jq` cases.
@MikeMcQuaid MikeMcQuaid force-pushed the list-versions-json-fast-path branch from b74a951 to 36acefd Compare May 20, 2026 19:24
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 01e3b54 May 21, 2026
37 checks passed
@MikeMcQuaid MikeMcQuaid deleted the list-versions-json-fast-path branch May 21, 2026 06:58
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.

3 participants