Filter hidden directories relative to every include root - #4528
Open
willemkokke wants to merge 1 commit into
Open
Filter hidden directories relative to every include root#4528willemkokke wants to merge 1 commit into
willemkokke wants to merge 1 commit into
Conversation
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.
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.) |
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.
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::RelativeToallowance carried onlyimport_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 fromuse_ignore_files, so--use-ignore-files=falsedegraded the filter toHiddenDirFilter::Alland 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_componentchecks 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_rootcovers a src-layout project under.claude/worktrees/…with atests/include, in bothuse_ignore_filesstates, and assertssrc/.venv/…is still excluded; it fails onmain(tests/check.pynot covered) and passes with the fix. The existingtest_get_filtered_globs_coverage_scopeexpectation is updated to the newRelativeToconstruction.cargo test -p pyrefly_configpasses.