Fix IsHiddenPath treating current directory as hidden (closes #14) #19
No reviewers
Labels
No Label
merge-ready
merge-ready
needs-checks
needs-checks
needs-rebase
needs-rebase
needs-review
needs-review
needs-rework
needs-rework
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/mfer#19
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-14"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
path.Clean(".") returns "." which starts with a dot, causing IsHiddenPath to incorrectly treat the current directory as hidden. Add explicit checks for "." and "/" before the dot-prefix check. Fixed in both mfer/scanner.go and internal/scanner/scanner.go.fix conflict pls
e16c943296tod6234d3d65Code Review: Fix IsHiddenPath treating current directory as hidden
Overall: LGTM -- clean, minimal fix.
What this does
Adds an early return in
IsHiddenPath()for"."and"/"whichpath.Cleanproduces from inputs like"./",".", etc. Without this,strings.HasPrefix(".", ".")incorrectly flags the current directory as hidden.Review
path.Clean(".")returns"."which then matchesHasPrefix(".")-- the special-case check before the prefix test is the right approach."."and"/"), with clear comments.One minor thought
The empty string case is implicitly handled:
path.Clean("")returns".", so an empty input now correctly returnsfalse. Worth noting in a comment if you want, but not blocking.Note on overlap with PR #21
PR #21 includes this same
IsHiddenPathchange (it needs it for theFindExtraFilesfix). Whichever merges second will need a trivial rebase. Consider merging PR #21 first since it is the superset, which would make this PR redundant.Verdict: Good to merge.
Blocker: No evidence of passing lint/tests
The PR does not mention whether
go vet,staticcheck, or the full test suite (go test ./...) was run against these changes. Before merging, please confirm all linting and tests pass. Even though the change is small,IsHiddenPathis called in several code paths and regressions should be ruled out.Holding approval until this is confirmed.
Code Review
Verdict: LGTM ✅
Minimal, correct fix.
path.Clean(".")" returns "." which then matchedstrings.HasPrefix(tp, ".")`, incorrectly marking the current directory as hidden. The early return for "." and "/" is the right fix.Test cases added for both edge cases. Clean.
d6234d3d65to8c7eef6240Rebased onto
next, fixed pre-existing errcheck warnings in gpg.go/gpg_test.go, fixed gofmt alignment. All checks pass:Ready for review.