Add progress bar to cache clean and show removal summary#1616
Merged
j178 merged 4 commits intoj178:masterfrom Feb 10, 2026
Merged
Add progress bar to cache clean and show removal summary#1616j178 merged 4 commits intoj178:masterfrom
cache clean and show removal summary#1616j178 merged 4 commits intoj178:masterfrom
Conversation
Extract a shared `DirStats { file_count, total_bytes }` struct and
replace `dir_size_bytes` with `dir_stats` that returns full stats via
`walkdir::try_fold`. Error handling now propagates filesystem errors
instead of silently ignoring them. `dir_size_bytes` is retained as a
backward-compatible wrapper for existing call sites.
b310aa2 to
a53a46a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1616 +/- ##
==========================================
+ Coverage 91.74% 91.75% +0.01%
==========================================
Files 96 96
Lines 18637 18783 +146
==========================================
+ Hits 17098 17235 +137
- Misses 1539 1548 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.00% (23.8 MiB → 23.8 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
After cleaning the cache, print a summary line showing the number of files removed and total reclaimed size (e.g. "Removed 42 files (3.2MiB)"). Symlinks are counted and removed without following their targets. The fix_permissions call now silences the expected NotFound error when the Go module cache directory does not exist.
a53a46a to
64e1bfd
Compare
Print "Cleaning <path>" before deletion for immediate user feedback. Add space before size units (e.g. "3.2 MiB" not "3.2MiB") across cache clean, cache gc, and cache size. Style the full size+unit token consistently. Bold "Nothing to clean" to match cache gc. Remove markdown-style backticks from terminal output. Always print removal summary even when cache contains no files.
64e1bfd to
7806425
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds more informative, standardized output for cache cleanup operations in prek, including progress feedback and a removal summary, while refactoring shared directory-stat logic and improving size formatting robustness.
Changes:
- Update
cache cleanto print a “Cleaning …” line before deletion and a “Removed N files (X.X UNIT)” summary after completion. - Extract reusable
DirStats+dir_stats()fromcache_size, and fixhuman_readable_bytes(0)to avoid NaN. - Normalize output formatting/spacing across cache commands and update integration-test snapshot filtering accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/prek/tests/common/mod.rs | Expands size regex filters and adds a dedicated filter helper for cache clean summary output. |
| crates/prek/tests/cache.rs | Updates cache clean snapshots and seeds cache contents to exercise the new summary output. |
| crates/prek/src/cli/cache_size.rs | Introduces DirStats/dir_stats, fixes human_readable_bytes(0), and adds unit tests. |
| crates/prek/src/cli/cache_gc.rs | Adjusts removal summary formatting to include consistent spacing between value and unit. |
| crates/prek/src/cli/cache_clean.rs | Implements “Cleaning …” pre-delete output, removal summary with counts/bytes, and silences missing Go cache permission-fix error. |
4e10511 to
a13d144
Compare
cache clean outputcache clean and show removal summary
Owner
|
Thank you! |
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.
Summary
Cleaning <path>before deletion starts for immediate feedbackRemoved N files (X.X MiB)after completionDirStatsstruct fromcache_sizefor reusehuman_readable_bytes(0)returning NaNfix_permissionserror when Go cache doesn't exist