Keep the current internal package API file on brew cleanup -s#23111
Merged
Conversation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Homebrew’s cache scrubbing behavior so brew cleanup -s no longer deletes the current internal package API cache file it just downloaded, avoiding repeated download/delete cycles while still removing older per-tag cache files.
Changes:
- Adjust
Cleanup#cache_filesto exclude the current effective-tagpackages.*.jws.jsonfrom scrub deletion while still sweeping other tag files. - Update the cleanup spec to use an injected cache root and assert only the stale internal package file is removed, while
formula.jws.jsonandcask.jws.jsonremain.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/cleanup.rb | Keeps the current internal packages JWS cache file during scrub by rejecting it from the packages.*.jws.json sweep. |
| Library/Homebrew/test/cleanup_spec.rb | Refactors the scrub test to seed a temp cache with current+stale packages files and assert only the stale one is removed. |
💡 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.
Every internal Ruby command fetches the current
api/internal/packages.<tag>.jws.jsonbefore it runs, but #23022 madebrew cleanup -sremove everypackages.*.jws.jsonfile. A standalonebrew cleanup -stherefore deletes the file it just downloaded, and each rerun re-downloads then re-deletes it. Follow-up to #23022, discussed in https://github.com/orgs/Homebrew/discussions/6962.brew cleanup -snow keeps thepackages.*.jws.jsonfile for the current effective tag and only sweeps the others left by older OSes or--os/--archruns. The kept file is matched by the basename ofHomebrew::API::Internal.cached_packages_json_file_path, so an injected cache root still resolves it. This mirrorsbrew update, which retains the current bottle-tag package file and prunes previous-tag ones. Normalbrew cleanupstill leaves every file untouched, andformula.jws.jsonandcask.jws.jsonare unaffected.The regression test seeds an injected cache with the current-tag file and a stale one, then asserts scrub keeps the current file, removes the stale one, and leaves
formula.jws.jsonandcask.jws.jsonin place.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 4.8) wrote the cleanup change and spec; I reviewed the diff and verified with
brew lgtmplus targetedcleanupspecs.