fix(core): improve parent gitignore handling for nested Nx workspaces #31911
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.
Current Behavior
When an Nx workspace exists inside a subdirectory of another git repository or when parent directories contain
.gitignore
files, those ignore patterns can affect file traversal within the Nx workspace, making project resolution non-deterministic.For example, if a workspace is inside a directory with
*
in its.gitignore
, Nx fails to properly traverse workspace files.Expected Behavior
Nx should respect
.gitignore
files in a smart way:This ensures deterministic project resolution regardless of where the workspace is located.
Related Issue(s)
Fixes #27368, #28000, #27295, #28123, #29413
Supersedes #29245 (incorporates feedback from @Cammisuli and @adamalton)
Implementation Details
The fix implements smart gitignore boundary detection that:
.gitignore
filesThis approach addresses the feedback from the original PR #29245 to handle both:
The solution leverages the
ignore
crate's existing functionality while providing precise control over which ignore files are considered.Test Plan
🤖 Generated with Claude Code