Skip to content

Dependency flow can target specific directories#5250

Merged
dkurepa merged 42 commits into
dotnet:mainfrom
dkurepa:dkurepa/DependencyFlowEnhancment
Sep 11, 2025
Merged

Dependency flow can target specific directories#5250
dkurepa merged 42 commits into
dotnet:mainfrom
dkurepa:dkurepa/DependencyFlowEnhancment

Conversation

@dkurepa

@dkurepa dkurepa commented Sep 5, 2025

Copy link
Copy Markdown
Member

#5220

  • Adds support for target directories in dependency flow subs. These paths are used to fetch the dependency files we're updating
  • Simplifies how we do dependency updates, because 1 subscription trigger can only have a non coherency update and a coherency update, so there was no need for a list

@dkurepa dkurepa changed the title Dependency flow can target specific directories [WIP] Dependency flow can target specific directories Sep 5, 2025
@dkurepa dkurepa marked this pull request as ready for review September 8, 2025 14:44
Copilot AI review requested due to automatic review settings September 8, 2025 14:44
@dkurepa dkurepa changed the title [WIP] Dependency flow can target specific directories Dependency flow can target specific directories Sep 8, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tools/ProductConstructionService.ReproTool/Operations/ReproOperation.cs Outdated
Comment thread tools/ProductConstructionService.ReproTool/Operations/Operation.cs Outdated
Comment thread test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs Outdated
Comment thread tools/ProductConstructionService.ReproTool/Operations/ReproOperation.cs Outdated
Comment thread src/Maestro/Maestro.MergePolicies/DependencyUpdateSummary.cs
Comment thread test/ProductConstructionService.DependencyFlow.Tests/PendingUpdatesTests.cs Outdated
Comment thread test/ProductConstructionService.DependencyFlow.Tests/PendingUpdatesTests.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/Models/Darc/AssetMatcher.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/AddSubscriptionPopUp.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/UpdateSubscriptionPopUp.cs Outdated
Comment thread test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs
Comment thread src/Microsoft.DotNet.Darc/Darc/Options/GetDependenciesCommandLineOptions.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/AddSubscriptionPopUp.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/AddSubscriptionPopUp.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/Models/Darc/AssetMatcher.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/Models/Darc/AssetMatcher.cs Outdated
Comment on lines +885 to +887
bool isRoot = targetDirectory == UnixPath.Empty;
List<AssetData> assetData = build.Assets
.Where(a => !excludedAssetsMatcher.IsExcluded(isRoot ? a.Name : $"{targetDirectory}/{a.Name}"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (take logical branching out of the loop):

Suggested change
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))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no TargetDirectory (for most dependency flow subs), this will cause a null reference exception

Comment thread src/Microsoft.DotNet.Darc/DarcLib/Helpers/LocalPath.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/UpdateSubscriptionPopUp.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Models/PopUps/AddSubscriptionPopUp.cs Outdated
premun
premun previously approved these changes Sep 11, 2025
@dkurepa dkurepa enabled auto-merge (squash) September 11, 2025 11:26
@dkurepa dkurepa requested a review from premun September 11, 2025 11:27
Comment on lines +57 to +66
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();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test for what happens when we do UnixPath.Empty / "foo"? Or when we do new UnixPath("foo") / UnixPath.Empty / "bar"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first one needs to be foo

@dkurepa dkurepa merged commit e554215 into dotnet:main Sep 11, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants