bundle/brew_services: avoid parsing output of brew services list#21830
bundle/brew_services: avoid parsing output of brew services list#21830
brew services list#21830Conversation
There was a problem hiding this comment.
Pull request overview
Updates brew bundle’s service detection to use brew services list --json instead of parsing the human-readable table output, aiming for more reliable parsing.
Changes:
- Switch
Homebrew::Bundle::Brew::Services.started_servicesto parse JSON frombrew services list --json. - Update the corresponding RSpec to stub JSON output instead of the table output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/bundle/brew_services.rb | Changes started_services to use JSON output from brew services list --json. |
| Library/Homebrew/test/bundle/brew_services_spec.rb | Updates the test fixture output to JSON to match the new implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`brew services` can output JSON, so let's use that instead since it should be more reliable.
3ccf253 to
ac06ea7
Compare
`brew services list --json` was returning early without any output when there were no services, causing `JSON.parse` to raise `JSON::ParserError` in callers expecting valid JSON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Much nicer, thanks @carlocab!
Now that bundle and services are both in the same repository we could consider dropping the shelling out entirely and just calling the native Homebrew methods?
Was considering that, but I wasn't yet sure that we didn't have other reasons for shelling out that still applied. I'll look at it in a follow-up. |
brew lgtm(style, typechecking and tests) with your changes locally?brew servicescan output JSON, so let's use that instead since itshould be more reliable.