fix(stdout): --depth ignores --show-apparent-size when sorting - #630
Open
VXNCXNX wants to merge 1 commit into
Open
fix(stdout): --depth ignores --show-apparent-size when sorting#630VXNCXNX wants to merge 1 commit into
VXNCXNX wants to merge 1 commit into
Conversation
printDirWithDepth was hardcoding fs.SortBySize, causing children to be ordered by disk usage even when apparent sizes were displayed. Extract sort field and order selection into a shared sortSettings helper used by both showDir and printDirWithDepth.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #630 +/- ##
=======================================
Coverage 87.04% 87.04%
=======================================
Files 69 69
Lines 7211 7211
=======================================
Hits 6277 6277
Misses 718 718
Partials 216 216 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
With
--depth, children are sorted by disk usage even when--show-apparent-sizeis set, so the rows print out of order against the sizes shown next to them. A directory holding a 50M sparse file next to one with a 5M dense file:showDiralready picksSortByApparentSizewhen the flag is set, butprintDirWithDepthhardcodedSortBySize. The selection now lives in a smallsortSettingshelper that both call, so they cannot drift again. Without-athe output is byte-identical to before, which I checked separately.Test added in
stdout_test.go; reverting the sort field fails it with "largest apparent size should be printed first".go test ./...passes, 18 packages. gofmt and vet clean.AI disclosure: written with Claude Code. I ran the binary before and after against a sparse file and checked the mutation myself.