NuGet: Filter out submodule paths during discovery#15093
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds submodule-aware filtering to NuGet discovery so Dependabot won’t attempt to discover/update projects or build files that live under git submodules (preventing corrupted PR output when repos include submodules).
Changes:
- Added
GitSubmoduleParserto parse.gitmodulesand identify submodule root paths. - Updated
DiscoveryWorker.RunAsyncto exclude discovered projects,global.json, anddotnet-tools.jsonthat are under submodule paths (with logging). - Added unit tests for
.gitmodulesparsing / path checks and a discovery scenario that filters submodule projects.
Show a summary per file
| File | Description |
|---|---|
| nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/GitSubmoduleParser.cs | New utility to extract submodule paths from .gitmodules and check whether a candidate path is inside a submodule. |
| nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs | Filters discovered projects and special files when they’re located under submodule directories. |
| nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/GitSubmoduleParserTests.cs | Adds tests for parsing .gitmodules content and identifying submodule-contained paths. |
| nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs | Adds a discovery test ensuring projects under a submodule directory are excluded. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 4
ryanbrandenburg
approved these changes
May 21, 2026
Parse .gitmodules in the repo root to identify submodule directories, then exclude any discovered projects, global.json, or dotnet-tools.json files that fall under those paths. Log when files are excluded. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…son test - Apply NormalizeUnixPathParts() in IsPathInSubmodule and ParseSubmodulePaths to handle paths with .. segments correctly - Add test cases for paths containing .. segments - Add GlobalJsonInSubmoduleIsFilteredOut test verifying global.json and dotnet-tools.json are excluded when workspace is in a submodule Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Filter projects in submodules before ExpandEntryPointsIntoProjectsAsync returns, preventing unnecessary project restore operations. The repoRootPath parameter is now required so submodule detection always runs during expansion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f496535 to
b733e1a
Compare
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.
Summary
During NuGet dependency discovery, the updater now parses
.gitmodulesin the repo root and excludes any projects,global.json, ordotnet-tools.jsonfiles that fall under submodule directories. This prevents the updater from attempting to update dependencies in submodules, which would produce corrupted PRs.Details
GitSubmoduleParserutility that parses.gitmodulesto extract submodule pathsDiscoveryWorker.RunAsyncto filter discovered projects and files against submodule pathsCloses #9433