info: avoid Formula/Cask objects for counts#21963
Open
MikeMcQuaid wants to merge 1 commit intomainfrom
Open
Conversation
6 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes brew info dependency/dependent counting by using installed keg Tab data and filesystem checks instead of instantiating Formula/Cask objects, reducing runtime overhead in interactive output.
Changes:
- Add a receipt/tab-based dependent counting helper and use keg tab
runtime_dependenciesfor recursive runtime counts. - Update cask dependency “installed?” checks to use Cellar/Caskroom directory existence.
- Adjust specs to create minimal Cellar/Caskroom state to exercise the new code paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Library/Homebrew/cmd/info.rb | Switches dependency/dependent counting to use Tab/Cellar inspection and adds a new counting helper. |
| Library/Homebrew/cask/info.rb | Avoids loading Formula/Cask objects when determining whether dependencies are installed. |
| Library/Homebrew/test/cmd/info_spec.rb | Updates formula info spec to build keg/tab fixtures in the Cellar. |
| Library/Homebrew/test/cask/info_spec.rb | Updates cask info spec to create Caskroom directories for “installed” detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0113887 to
446a930
Compare
- use Tab `runtime_dependencies` hashes and rack
directory existence instead of instantiating Formula
or Cask objects for dependency/dependent counts
- use `Keg.from_rack` for stable keg selection instead
of unsorted `rack.subdirs.last`
- strip tap prefix from dep names via `split("/").last`
so tap-qualified names resolve to the correct rack
- skip JSON parsing in `count_installed_dependents`
when the formula name doesn't appear in the raw
receipt file
- skip dependent counting entirely for non-TTY output
446a930 to
85f279d
Compare
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.
runtime_dependencieshashes and rack directory existence instead of instantiating Formula or Cask objects for dependency/dependent countsrack.subdirs.max_bymtime stat calls withrack.subdirs.lastsince dep names rarely change across versionscount_installed_dependentswhen the formula name doesn't appear in the raw receipt filebrew lgtm(style, typechecking and tests) with your changes locally?Used Claude Code with manual review and testing.