From e16c94329600a3be9a761fa0fa51832ea69a72f7 Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 8 Feb 2026 12:03:54 -0800 Subject: [PATCH] fix: IsHiddenPath returns false for "." and "/" (current dir/root are not hidden) 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. --- internal/scanner/scanner.go | 3 +++ mfer/scanner.go | 3 +++ mfer/scanner_test.go | 2 ++ 3 files changed, 8 insertions(+) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 252e16a..32ed579 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -331,6 +331,9 @@ func (s *Scanner) ToManifest(ctx context.Context, w io.Writer, progress chan<- S // start with a dot (hidden files/directories). func pathIsHidden(p string) bool { tp := path.Clean(p) + if tp == "." || tp == "/" { + return false + } if strings.HasPrefix(tp, ".") { return true } diff --git a/mfer/scanner.go b/mfer/scanner.go index df0df11..943fdd7 100644 --- a/mfer/scanner.go +++ b/mfer/scanner.go @@ -385,6 +385,9 @@ func (s *Scanner) ToManifest(ctx context.Context, w io.Writer, progress chan<- S // The path should use forward slashes. func IsHiddenPath(p string) bool { tp := path.Clean(p) + if tp == "." || tp == "/" { + return false + } if strings.HasPrefix(tp, ".") { return true } diff --git a/mfer/scanner_test.go b/mfer/scanner_test.go index b6e6296..55bc462 100644 --- a/mfer/scanner_test.go +++ b/mfer/scanner_test.go @@ -352,6 +352,8 @@ func TestIsHiddenPath(t *testing.T) { {"/absolute/.hidden", true}, {"./relative", false}, // path.Clean removes leading ./ {"a/b/c/.d/e", true}, + {".", false}, // current directory is not hidden + {"/", false}, // root is not hidden } for _, tt := range tests {