Skip to content

Keep the current internal package API file on brew cleanup -s#23111

Merged
MikeMcQuaid merged 1 commit into
mainfrom
cleanup-scrub-keep-current-package-api
Jul 14, 2026
Merged

Keep the current internal package API file on brew cleanup -s#23111
MikeMcQuaid merged 1 commit into
mainfrom
cleanup-scrub-keep-current-package-api

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

Every internal Ruby command fetches the current api/internal/packages.<tag>.jws.json before it runs, but #23022 made brew cleanup -s remove every packages.*.jws.json file. A standalone brew cleanup -s therefore 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 -s now keeps the packages.*.jws.json file for the current effective tag and only sweeps the others left by older OSes or --os/--arch runs. The kept file is matched by the basename of Homebrew::API::Internal.cached_packages_json_file_path, so an injected cache root still resolves it. This mirrors brew update, which retains the current bottle-tag package file and prunes previous-tag ones. Normal brew cleanup still leaves every file untouched, and formula.jws.json and cask.jws.json are 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.json and cask.jws.json in place.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

Claude Code (Opus 4.8) wrote the cleanup change and spec; I reviewed the diff and verified with brew lgtm plus targeted cleanup specs.


Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI review requested due to automatic review settings July 14, 2026 18:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_files to exclude the current effective-tag packages.*.jws.json from 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.json and cask.jws.json remain.

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.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid MikeMcQuaid enabled auto-merge July 14, 2026 18:42
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jul 14, 2026
Merged via the queue into main with commit 95eeda5 Jul 14, 2026
45 checks passed
@MikeMcQuaid MikeMcQuaid deleted the cleanup-scrub-keep-current-package-api branch July 14, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants