From 34e2e9db33a46ea16a349ac304c3deba015d0cc6 Mon Sep 17 00:00:00 2001 From: Tristan Manchester Date: Fri, 17 Apr 2026 09:24:48 +0200 Subject: [PATCH] Preserve hidden path prefixes in exclusions --- desloppify/base/discovery/file_paths.py | 2 +- desloppify/tests/core/test_utils.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/desloppify/base/discovery/file_paths.py b/desloppify/base/discovery/file_paths.py index fcf0dcf34..8cd41080d 100644 --- a/desloppify/base/discovery/file_paths.py +++ b/desloppify/base/discovery/file_paths.py @@ -21,7 +21,7 @@ def matches_exclusion(rel_path: str, exclusion: str) -> bool: # Full-path glob match for patterns with directory separators # (e.g. "Wan2GP/**" should match "Wan2GP/models/rf.py"). if "/" in exclusion or os.sep in exclusion: - normalized_path = rel_path.lstrip("./") + normalized_path = rel_path.removeprefix("./") if fnmatch.fnmatch(normalized_path, exclusion): return True if "/" in exclusion or os.sep in exclusion: diff --git a/desloppify/tests/core/test_utils.py b/desloppify/tests/core/test_utils.py index 8d1b43f19..d5f19a5c0 100644 --- a/desloppify/tests/core/test_utils.py +++ b/desloppify/tests/core/test_utils.py @@ -140,6 +140,12 @@ def test_matches_exclusion_exact_directory_path(): assert matches_exclusion(".claude/worktrees", ".claude/worktrees") is True +def test_matches_exclusion_hidden_dir_globs_preserve_leading_dot(): + """Hidden directories should not match non-hidden glob prefixes.""" + assert matches_exclusion(".cache/subdir/file.py", "cache/**") is False + assert matches_exclusion(".cache/subdir/file.py", ".cache/**") is True + + # ── find_source_files() ─────────────────────────────────────