fix(core): improve parent gitignore handling for nested Nx workspaces#31911
Merged
FrozenPandaz merged 1 commit intomasterfrom Jul 17, 2025
Merged
fix(core): improve parent gitignore handling for nested Nx workspaces#31911FrozenPandaz merged 1 commit intomasterfrom
FrozenPandaz merged 1 commit intomasterfrom
Conversation
Implements smart gitignore boundary detection that respects parent gitignore files only up to the nearest git repository root, preventing external gitignore files (e.g., in home directory) from affecting workspace traversal. **Behavior:** - **Workspace is git root**: Ignores all parent gitignore files - **Workspace nested in git repo**: Respects gitignore files within the git repository but ignores any gitignore files above the git root - **No git repo found**: Respects all parent gitignore files (backwards compatibility) This resolves issues where workspaces would have missing projects or files when parent directories contained overly broad gitignore patterns like "*". The solution addresses feedback from PR #29245 to handle both standalone workspaces and workspaces nested within larger git repositories. Fixes #27368, #28000, #27295, #28123, #29413 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
|
View your CI Pipeline Execution ↗ for commit 0a430ed
☁️ Nx Cloud last updated this comment at |
FrozenPandaz
approved these changes
Jul 17, 2025
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
.gitignorefiles, 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
.gitignorefiles 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:
.gitignorefilesThis approach addresses the feedback from the original PR #29245 to handle both:
The solution leverages the
ignorecrate's existing functionality while providing precise control over which ignore files are considered.Test Plan
🤖 Generated with Claude Code