Skip to content

fix(cache): honor plugin filter when pruning cache#9914

Merged
jdx merged 2 commits into
jdx:mainfrom
risu729:cache-prune-tool-filter
May 17, 2026
Merged

fix(cache): honor plugin filter when pruning cache#9914
jdx merged 2 commits into
jdx:mainfrom
risu729:cache-prune-tool-filter

Conversation

@risu729

@risu729 risu729 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Honor the optional mise cache prune [PLUGIN]... argument instead of always pruning the whole cache.
  • Mirror mise cache clear by mapping each requested plugin name to its cache subdirectory before pruning stale files.
  • Leave env-cache pruning on the unscoped mise cache prune path only, because the env cache is not scoped to a single plugin directory.
  • Reword the prune argument help from "clear cache" to "prune cache" while leaving cache clear wording unchanged.

Behavior

Before this change, mise cache prune node accepted node but ignored it and pruned all cache directories, plus the env cache. With this change, mise cache prune node only prunes stale files under the node cache directory. Running mise cache prune with no arguments keeps the existing all-cache behavior.

Testing

  • cargo fmt --all -- --check
  • git diff --check
  • mise run test:e2e e2e/cli/test_cache_prune_plugin

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request enhances the mise cache prune command by allowing users to target specific plugins for cache removal and adds a corresponding end-to-end test. The implementation includes logic to convert plugin names to kebab-case and updates the command's output to list the specific plugins processed. The review feedback correctly identifies a terminology error where the word "clear" was replaced with "prune" in the help text for the clear command across documentation, man pages, and completion specs. Since clear performs a full deletion while prune is age-based, the feedback advises reverting these specific text changes to maintain semantic clarity for users.

Comment thread docs/mise.usage.kdl Outdated
Comment thread man/man1/mise.1 Outdated
Comment thread mise.usage.kdl Outdated
Comment thread xtasks/fig/src/mise.ts Outdated
@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes mise cache prune to honor the optional [PLUGIN]… argument, which was previously accepted but silently ignored. The implementation closely mirrors the existing cache clear command by mapping each plugin name to its kebab-case cache subdirectory and skipping env-cache pruning when a plugin filter is active.

  • src/cli/cache/prune.rs: Adds plugin-scoped directory resolution using heck::ToKebabCase (identical to clear.rs), gates env-cache pruning on self.plugin.is_none(), and updates the info message to list the targeted plugins.
  • e2e/cli/test_cache_prune_plugin: New end-to-end test creates stale files under both node and python cache dirs, runs mise cache prune node, and asserts only the node dir was pruned.
  • Docs/completions (man/man1/mise.1, mise.usage.kdl, docs/cli/cache/prune.md, xtasks/fig/src/mise.ts): Argument description updated from "clear cache" to "prune cache" exclusively in the prune-command sections; cache clear sections are untouched.

Confidence Score: 5/5

Safe to merge — the change is a narrow, well-scoped bug fix that only affects mise cache prune when explicit plugin names are passed.

The new code path directly mirrors the battle-tested cache clear implementation: same to_kebab_case mapping, same p.exists() guard, same env-cache gating. The e2e test exercises the core scenario. All documentation changes are confined to the correct prune-command sections.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/cache/prune.rs Core fix: plugin-scoped pruning now mirrors the cache clear pattern, correctly skipping env-cache when plugins are specified and using the same kebab-case path mapping.
e2e/cli/test_cache_prune_plugin New e2e test correctly verifies that only the requested plugin's cache is pruned while other plugins' caches are left intact.
docs/cli/cache/prune.md Updated [PLUGIN] description from "clear cache" to "prune cache" — correctly scoped to the prune command doc.
man/man1/mise.1 Change at line 742 is correctly inside the MISE CACHE PRUNE section; the MISE CACHE CLEAR section at line 721 is untouched.
mise.usage.kdl Description update is correctly applied only to the cmd prune block; cmd clear at line 143 retains "clear cache".
xtasks/fig/src/mise.ts Description update is correctly in the ["prune", "p"] block at line 728; the cache clear block at line 700 is untouched.

Reviews (2): Last reviewed commit: "docs(cache): fix generated cache clear w..." | Re-trigger Greptile

Comment thread man/man1/mise.1
@risu729 risu729 marked this pull request as ready for review May 16, 2026 14:10
@jdx jdx merged commit 5797849 into jdx:main May 17, 2026
33 checks passed
@risu729 risu729 deleted the cache-prune-tool-filter branch May 17, 2026 15:32
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.

2 participants