bundle: add base class helpers and DRY up extension executable handling#21854
Open
costajohnt wants to merge 3 commits intoHomebrew:mainfrom
Open
bundle: add base class helpers and DRY up extension executable handling#21854costajohnt wants to merge 3 commits intoHomebrew:mainfrom
costajohnt wants to merge 3 commits intoHomebrew:mainfrom
Conversation
Add `package_manager_executable!` and `with_package_manager_env` helpers to the Extension base class. Refactor all extensions to use them, eliminating repeated nil-check boilerplate and inline env setup.
Rename &blk to &_blk to satisfy RuboCop Lint/UnusedMethodArgument while keeping yield for Performance/RedundantBlockCall.
MikeMcQuaid
reviewed
Mar 28, 2026
Member
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Much nicer thanks! One thought.
| { "PATH" => "#{executable.dirname}:#{ORIGINAL_PATHS.join(":")}" } | ||
| end | ||
|
|
||
| sig { params(_blk: T.proc.params(executable: Pathname).returns(T.untyped)).returns(T.untyped) } |
Member
There was a problem hiding this comment.
Would be good to avoid T.untyped here. Ideally make this an actual type, if not make it T.anything if possible.
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.
Follow-up to #21802 as requested in review feedback.
Adds two helpers to the
Extensionbase class and refactors all extensions to use them:package_manager_executable!— returnsPathnameor raises with a clear error message, eliminating the repeatedexe = package_manager_executable; return false if exe.nil?pattern across all extensionswith_package_manager_env— block helper that gets the executable, sets up the PATH env, and yields the executable, DRYing up the get-executable + set-env + run-command patternExtensions refactored: cargo, go, uv, krew, npm, vscode, mac_app_store, flatpak
brew lgtm(style, typechecking and tests) with your changes locally?brew typecheck), and tests (brew tests --only=bundle) pass locally.