Skip to content

Filter hidden directories relative to every include root - #4528

Open
willemkokke wants to merge 1 commit into
facebook:mainfrom
willemkokke:fix/hidden-dir-filter-include-roots
Open

Filter hidden directories relative to every include root#4528
willemkokke wants to merge 1 commit into
facebook:mainfrom
willemkokke:fix/hidden-dir-filter-include-roots

Conversation

@willemkokke

Copy link
Copy Markdown

Fixes #4526. One of the two PRs replacing #4402, split per review feedback — the other is #4527 (crates/pyrefly_util/src/globs.rs). The two touch disjoint files and can land in either order.

Problem. Follow-up to #2402. The HiddenDirFilter::RelativeTo allowance carried only import_root, so for a src-layout project (import_root = <project>/src) an include outside it — tests/check.py — prefix-matched no root and fell back to absolute-path component checking, where a checkout under a hidden directory (~/.codex/worktrees/…, .claude/worktrees/…) has every ancestor chain hidden and the include was silently dropped. The root list was also derived from use_ignore_files, so --use-ignore-files=false degraded the filter to HiddenDirFilter::All and hid the project entirely.

Approach. Build the allowance from every include root plus the import root, independent of use_ignore_files.

Why it works. has_hidden_component checks components relative to the most specific matching root, so listing every root the project actually declares means each of the project's files is judged relative to a root it lives under — hidden ancestors above the project stop mattering, while hidden directories inside it (src/.venv/…) are still excluded. And the allowance describes where the project lives, which has nothing to do with whether ignore files are consulted, so disabling one mechanism no longer hardens the other.

Tests. New test_hidden_dir_filter_is_relative_to_every_include_root covers a src-layout project under .claude/worktrees/… with a tests/ include, in both use_ignore_files states, and asserts src/.venv/… is still excluded; it fails on main (tests/check.py not covered) and passes with the fix. The existing test_get_filtered_globs_coverage_scope expectation is updated to the new RelativeTo construction. cargo test -p pyrefly_config passes.

The RelativeTo hidden-directory allowance carried only import_root, so
for a src-layout project (import_root = src/) any include outside it --
tests/check.py -- fell back to absolute-path component checking, where
a checkout under a hidden directory (~/.codex/worktrees/...,
.claude/worktrees/...) has every path hidden and the include was
skipped. The roots are now every include root plus the import root.

Also decouples the allowance from use_ignore_files: the root list was
only populated when ignore files were enabled, so --use-ignore-files=
false degraded the filter to HiddenDirFilter::All and made hidden-
directory filtering stricter -- disabling one exclusion mechanism
silently hardened another.
@meta-codesync

meta-codesync Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D115778066. (Because this pull request was imported automatically, there will not be any future comments.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HiddenDirFilter::RelativeTo carries only import_root, so includes outside it are dropped under a hidden-directory checkout

1 participant