Dependency flow can target specific directories#5250
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for dependency flow subscriptions to target specific directories rather than just the repository root. This allows for more granular control over where dependency updates are applied within a repository.
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs | Core logic to handle multiple target directories and process dependency updates per directory |
| src/ProductConstructionService.DependencyFlow/PullRequestBuilder.cs | Updates to PR building logic to handle multiple directory updates and commit messages |
| src/ProductConstructionService.DependencyFlow/Model/ | New model classes for directory-specific dependency updates |
| src/Microsoft.DotNet.Darc/DarcLib/Remote.cs | Enhanced remote operations to support relative base paths for dependency operations |
| src/Microsoft.DotNet.Darc/DarcLib/Models/Darc/AssetMatcher.cs | Extended asset matching to work with multiple directories and path-specific filters |
| test/ | Updated test files to support the new directory-based dependency flow functionality |
| tools/ | Updated repro tools to handle target directory parameters |
Co-authored-by: Přemek Vysoký <[email protected]>
| bool isRoot = targetDirectory == UnixPath.Empty; | ||
| List<AssetData> assetData = build.Assets | ||
| .Where(a => !excludedAssetsMatcher.IsExcluded(isRoot ? a.Name : $"{targetDirectory}/{a.Name}")) |
There was a problem hiding this comment.
nit (take logical branching out of the loop):
| bool isRoot = targetDirectory == UnixPath.Empty; | |
| List<AssetData> assetData = build.Assets | |
| .Where(a => !excludedAssetsMatcher.IsExcluded(isRoot ? a.Name : $"{targetDirectory}/{a.Name}")) | |
| string directoryPrefix = string.IsNullOrEmpty(targetDirectory) ? "" : $"{targetDirectory}/"; | |
| List<AssetData> assetData = build.Assets | |
| .Where(a => !excludedAssetsMatcher.IsExcluded(directoryPrefix + a.Name)) |
There was a problem hiding this comment.
95% of these updates are going to be in the root directory. I wonder if the branching overhead in the loop beats the overhead of constant string allocation
| .Where(a => !excludedAssetsMatcher.IsExcluded(a.Name)) | ||
| .Select(a => new AssetData(false) | ||
| List<UnixPath> targetDirectories; | ||
| if (string.IsNullOrEmpty(subscription.TargetDirectory)) |
There was a problem hiding this comment.
This condition is technically unnecessary. You could remove the if/else and your Split(',') command a few lines under would pick up the empty string for subscription.TargetDirectory and correctly interpret it as UnixPath.Empty when you do targetDirectories.Add(new UnixPath(d));
There was a problem hiding this comment.
if there is no TargetDirectory (for most dependency flow subs), this will cause a null reference exception
…nPopUp.cs Co-authored-by: Přemek Vysoký <[email protected]>
…pUp.cs Co-authored-by: Přemek Vysoký <[email protected]>
| public void UnixPathEqualityTest() | ||
| { | ||
| var emptyPath1 = new UnixPath(""); | ||
| var emptyPath2 = UnixPath.Empty; | ||
| var dotPath = new UnixPath("."); | ||
|
|
||
| (emptyPath1 == emptyPath2).Should().BeTrue(); | ||
| (emptyPath1 == dotPath).Should().BeTrue(); | ||
| (emptyPath2 == dotPath).Should().BeTrue(); | ||
| } |
There was a problem hiding this comment.
Can we have a test for what happens when we do UnixPath.Empty / "foo"? Or when we do new UnixPath("foo") / UnixPath.Empty / "bar"?
There was a problem hiding this comment.
UnixPath.Empty / "foo" return /foo and new UnixPath("foo") / UnixPath.Empty / "bar" returns foo/bar. I'm not sure if the first one is expected, maybe we'd just expect foo there?
#5220