Skip to content

Allow darc update-dependencies to update specific VMR folders with target-directory#5340

Merged
dkurepa merged 9 commits into
dotnet:mainfrom
dkurepa:dkurepa/UpdateDependenciesEnhancments
Oct 7, 2025
Merged

Allow darc update-dependencies to update specific VMR folders with target-directory#5340
dkurepa merged 9 commits into
dotnet:mainfrom
dkurepa:dkurepa/UpdateDependenciesEnhancments

Conversation

@dkurepa

@dkurepa dkurepa commented Oct 6, 2025

Copy link
Copy Markdown
Member

@dkurepa dkurepa marked this pull request as ready for review October 6, 2025 14:14
Copilot AI review requested due to automatic review settings October 6, 2025 14:14
@dkurepa dkurepa changed the title Dkurepa/update dependencies enhancments Allow darc update-dependencies to update specific VMR folders with target-directory Oct 6, 2025
@dkurepa dkurepa requested review from adamzip and premun October 6, 2025 14:15

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 introduces enhancements to dependency update functionality, adding support for targeting specific directories (including simple globbing) and excluding assets per directory, along with related refactoring to modularize update logic and extend asset matching.

  • Added per-directory dependency update workflow with optional glob expansion and root/path handling.
  • Introduced asset exclusion with relative path-aware matching and refactored update logic into smaller helper methods.
  • Extended APIs (IAssetMatcher, Local.UpdateDependenciesAsync) and added new command-line options (target-directory, excluded-assets).

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
AssetMatcher.cs Added path-aware exclusion overload to matcher interface and implementation.
Local.cs Extended UpdateDependenciesAsync to support relative base paths and adjusted eng/common file path rewriting.
UpdateDependenciesCommandLineOptions.cs Added target-directory and excluded-assets options with help text.
UpdateDependenciesOperation.cs Major refactor: directory-scoped update flow, asset exclusion integration, task reuse, and decomposition into helper methods.

Comment thread src/Microsoft.DotNet.Darc/DarcLib/Models/Darc/AssetMatcher.cs
Comment on lines +120 to +132
string pathToReplaceWith;
if (relativeDependencyBasePath == UnixPath.Empty)
{
pathToReplaceWith = null;
}
else
{
pathToReplaceWith = relativeDependencyBasePath.ToString();
}

engCommonFiles = engCommonFiles
.Select(f => new GitFile(
f.FilePath.Replace("src/arcade/", null),
f.FilePath.Replace(VmrInfo.ArcadeRepoDir, pathToReplaceWith, StringComparison.InvariantCultureIgnoreCase).TrimStart('/'),

Copilot AI Oct 6, 2025

Copy link

Choose a reason for hiding this comment

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

pathToReplaceWith can be null, which will cause string.Replace to throw an ArgumentNullException. Use string.Empty instead of null when you intend to remove the prefix.

Copilot uses AI. Check for mistakes.
Comment thread src/Microsoft.DotNet.Darc/DarcLib/Local.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs Outdated
Comment on lines +341 to +344
if (nonCoherencyResult != Constants.SuccessCode)
{
_logger.LogError(" Failed to update non-coherent parent tied dependencies.");
return;

Copilot AI Oct 6, 2025

Copy link

Choose a reason for hiding this comment

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

On failure this method logs and returns without propagating an error, allowing the caller to continue and potentially perform coherency updates on stale data. Consider throwing or returning a status so the caller can abort the directory update.

Copilot uses AI. Check for mistakes.
Comment thread src/Microsoft.DotNet.Darc/Darc/Options/UpdateDependenciesCommandLineOptions.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs Outdated
@dkurepa dkurepa merged commit 5123781 into dotnet:main Oct 7, 2025
9 checks passed
@ellahathaway

Copy link
Copy Markdown
Member

@dkurepa I'm seeing some issues with darc that look related to the changes in this PR:

dnx microsoft.dotnet.darc --prerelease -- update-dependencies --id <id> --ci --dry-run                                            
Path root
fail: Failed to update dependencies.
      System.NullReferenceException: Object reference not set to an instance of an object.
         at Microsoft.DotNet.Darc.Operations.UpdateDependenciesOperation.<>c__DisplayClass10_0.<NonCoherencyUpdatesForBuild>b__0(Asset a) in /_/src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs:line 125
         at System.Linq.Enumerable.WhereSelectListIterator`2.ToList()
         at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         at Microsoft.DotNet.Darc.Operations.UpdateDependenciesOperation.NonCoherencyUpdatesForBuild(Build build, List`1 currentDependencies, List`1 candidateDependenciesForUpdate, List`1 dependenciesToUpdate, IAssetMatcher excludedAssetsMatcher, UnixPath relativeBasePath) in /_/src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs:line 124
         at Microsoft.DotNet.Darc.Operations.UpdateDependenciesOperation.RunNonCoherencyUpdateForSpecificBuild(List`1 currentDependencies, List`1 candidateDependenciesForUpdate, List`1 dependenciesToUpdate, IAssetMatcher excludedAssetsMatcher, UnixPath relativeBasePath) in /_/src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs:line 341
         at Microsoft.DotNet.Darc.Operations.UpdateDependenciesOperation.UpdateDependenciesInDirectory(UnixPath relativeBasePath, Local local, ConcurrentDictionary`2 latestBuildTaskDictionary, IAssetMatcher excludedAssetsMatcher) in /_/src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs:line 214
         at Microsoft.DotNet.Darc.Operations.UpdateDependenciesOperation.ExecuteAsync() in /_/src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs:line 66

@dkurepa

dkurepa commented Oct 8, 2025

Copy link
Copy Markdown
Member Author

Thanks for catching this @ellahathaway. I made a regression in one of the commits and didn't test that code path with no excluded assets. Opened a PR to fix it #5347

dkurepa added a commit that referenced this pull request Oct 8, 2025
<!-- Link the GitHub or AzDO issue this pull request is associated with.
Please copy and paste the full URL rather than using the
dotnet/arcade-services# syntax -->
#5221 fixes a bug
introduced in #5340 where
there's an NRE if there are no excluded assets
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