Add list versions JSON#22360
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 --jsoninLibrary/Homebrew/list.sh, producing JSON for formulae/casks including linked/opt-linked/pinned versions. - Add
--jsonflag 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.
- 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.
b74a951 to
36acefd
Compare
p-linnane
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jq.list.shin tests to avoid checkoutCellarstate.--jsonfor manpages while Ruby fails if reached.jqcases.brew lgtm(style, typechecking and tests) with your changes locally?OpenAI Codex 5.5 xhigh with local review and testing.