Fix caveats replacing order (HOMEBREW_PREFIX) in API formula reconstruction#22810
Open
umireon wants to merge 2 commits into
Open
Fix caveats replacing order (HOMEBREW_PREFIX) in API formula reconstruction#22810umireon wants to merge 2 commits into
umireon wants to merge 2 commits into
Conversation
$HOMEBREW_PREFIX prefiexed with / (e.g. unix://$HOMEBREW_PREFIX) results in broken path. This is because `/$HOME` is replaced before `$HOMEBREW_PREFIX` in API. Signed-off-by: Kaito Udagawa <umireon@kaito.tokyo>
Contributor
Author
|
Waiting for initial test case failure |
Use the same order as formulary.rb. Signed-off-by: Kaito Udagawa <umireon@kaito.tokyo>
Contributor
Author
|
Test passed. I'm confident with this PR to fix the bug. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a placeholder-replacement ordering issue when reconstructing Formula data from the API, preventing $HOMEBREW_PREFIX (and $HOMEBREW_CELLAR) from being partially rewritten by the /$HOME placeholder replacement in strings like unix://$HOMEBREW_PREFIX.
Changes:
- Reorder placeholder substitutions in
APIHashable#deep_remove_placeholdersto replace prefix/cellar before home. - Add an RSpec regression test ensuring
unix://$HOMEBREW_PREFIXis reconstructed correctly inFormulaStruct.from_hash.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Library/Homebrew/api_hashable.rb |
Fixes placeholder replacement order to avoid /$HOME matching inside /$HOMEBREW_PREFIX//$HOMEBREW_CELLAR. |
Library/Homebrew/test/api/formula_struct_spec.rb |
Adds a regression test covering the previously broken unix://$HOMEBREW_PREFIX caveats reconstruction case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
$HOMEBREW_PREFIX prefiexed with / (e.g. unix://$HOMEBREW_PREFIX) results in broken path.
This is because
/$HOMEis replaced before$HOMEBREW_PREFIXin API.This PR fixes the order of replacing HOMEBREW_PREFIX, HOMEBREW_CELLAR, HOME.
Actual behavior
Expected behavior
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?I used OpenAI Codex to investigate the root cause of this bug. I wrote all the code by my hands and carefully examined thoroughly. I have run test and actual command repeatedly to confirm this change works as expected.