Skip to content

Commit a6275b2

Browse files
authored
[Rollout] Production rollout 2025-08-22 (#5187)
#5186
2 parents afe3fb3 + 79fb62c commit a6275b2

File tree

21 files changed

+76
-118
lines changed

21 files changed

+76
-118
lines changed

eng/Create-CodeflowGraphVizGraph.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ function Get-GitCommits {
920920
# Get the commit history in format: <sha> <parent-sha>
921921
# This gives us both the commit SHA and its parent commit SHA
922922
# We use the %P format to get all parent SHAs (important for merge commits)
923-
$commits = git -C $repoPath log -n $count --format="%H %P" main
923+
$commits = git -C $repoPath log -n $count --format="%H %P"
924924

925925
# Convert the raw git log output into structured objects
926926
$commitObjects = @()

src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/CodeFlowOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected async Task FlowCodeLocallyAsync(
7373
? new ForwardFlow(_options.Ref, await targetRepo.GetShaForRefAsync())
7474
: new Backflow(_options.Ref, await targetRepo.GetShaForRefAsync());
7575

76-
await _dependencyTracker.RefreshMetadata();
76+
await _dependencyTracker.RefreshMetadataAsync();
7777

7878
SourceMapping mapping = _dependencyTracker.GetMapping(mappingName);
7979

src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/GenerateTpnOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public GenerateTpnOperation(
2626

2727
public override async Task<int> ExecuteAsync()
2828
{
29-
await _dependencyTracker.RefreshMetadata();
29+
await _dependencyTracker.RefreshMetadataAsync();
3030
await _generator.UpdateThirdPartyNotices(_options.TpnTemplate);
3131
return 0;
3232
}

src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/GetRepoVersionOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public GetRepoVersionOperation(
3131
public override async Task<int> ExecuteAsync()
3232
{
3333
var repositories = _options.Repositories.ToList();
34-
await _dependencyTracker.RefreshMetadata();
34+
await _dependencyTracker.RefreshMetadataAsync();
3535

3636
// If there are no repositories, list all.
3737
if (!repositories.Any())

src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public override async Task<int> ExecuteAsync()
6767
_vmrInfo.VmrPath = new NativePath(_options.VmrPath);
6868

6969
// Validate that the mapping exists
70-
await _dependencyTracker.RefreshMetadata();
70+
await _dependencyTracker.RefreshMetadataAsync();
7171

7272
SourceMapping mapping;
7373
try
@@ -121,7 +121,7 @@ .. mapping.Exclude.Select(VmrPatchHandler.GetExclusionRule)
121121
var targetDir = _vmrInfo.GetRepoSourcesPath(mapping);
122122
var result = await _processManager.Execute(
123123
_processManager.GitExecutable,
124-
["rm", "-r", "-q", "--", .. removalFilters],
124+
["rm", "-r", "-q", "-f", "--", .. removalFilters],
125125
workingDir: targetDir);
126126

127127
result.ThrowIfFailed($"Failed to remove files in {targetDir}");

src/Microsoft.DotNet.Darc/DarcLib/Helpers/DependencyFileManager.cs

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ public async Task<GitFileContentContainer> UpdateDependencyFiles(
434434
string branch,
435435
IEnumerable<DependencyDetail> oldDependencies,
436436
SemanticVersion incomingDotNetSdkVersion,
437-
bool forceGlobalJsonUpdate = false,
438437
bool? repoHasVersionDetailsProps = null)
439438
{
440439
// When updating version files, we always want to look in the base folder, even when we're updating it in the VMR
@@ -509,7 +508,7 @@ public async Task<GitFileContentContainer> UpdateDependencyFiles(
509508
Dictionary<GitFileMetadataName, string> globalJsonMetadata = null;
510509
if (incomingDotNetSdkVersion != null)
511510
{
512-
globalJsonMetadata = UpdateDotnetVersionGlobalJson(incomingDotNetSdkVersion, globalJson, forceGlobalJsonUpdate);
511+
globalJsonMetadata = UpdateDotnetVersionGlobalJson(incomingDotNetSdkVersion, globalJson);
513512
}
514513

515514
var fileContainer = new GitFileContentContainer
@@ -559,60 +558,53 @@ public void UpdateVersionDetailsXmlSourceTag(XmlDocument versionDetails, SourceD
559558
}
560559

561560
/// <summary>
562-
/// Updates the global.json entries for tools.dotnet and sdk.version if they are older than an incoming version
561+
/// Updates the global.json entries for tools.dotnet and sdk.version in the repo if incoming version is newer
563562
/// </summary>
564-
/// <param name="incomingDotnetVersion">version to compare against</param>
565-
/// <param name="globalJson">Global.Json file to update</param>
566-
/// <param name="forceUpdate">Ignores version check and forces globalJson update</param>
563+
/// <param name="incomingDotnetVersion">incoming version to compare against</param>
564+
/// <param name="targetGlobalJson">Global.Json file to update in target repo</param>
567565
/// <returns>Updated global.json file if was able to update, or the unchanged global.json if unable to</returns>
568566
private Dictionary<GitFileMetadataName, string> UpdateDotnetVersionGlobalJson(
569567
SemanticVersion incomingDotnetVersion,
570-
JObject globalJson,
571-
bool forceUpdate = false)
568+
JObject targetGlobalJson)
572569
{
573-
try
570+
JToken pinnedToken = targetGlobalJson.SelectToken("tools.pinned");
571+
if (pinnedToken != null && pinnedToken.Type == JTokenType.Boolean && pinnedToken.Value<bool>())
574572
{
575-
// Check if tools.pinned is set to true, if so skip update
576-
JToken pinnedToken = globalJson.SelectToken("tools.pinned");
577-
if (pinnedToken != null && pinnedToken.Type == JTokenType.Boolean && pinnedToken.Value<bool>())
578-
{
579-
_logger.LogInformation("Skipping dotnet SDK update because tools.pinned is set to true in global.json");
580-
return null;
581-
}
573+
_logger.LogInformation("Skipping dotnet SDK update because tools.pinned is set to true in the target." +
574+
$"repo's {VersionFiles.GlobalJson}");
575+
return null;
576+
}
582577

583-
if (SemanticVersion.TryParse(globalJson.SelectToken("tools.dotnet")?.ToString(), out SemanticVersion repoDotnetVersion))
584-
{
585-
if (repoDotnetVersion.CompareTo(incomingDotnetVersion) < 0 || forceUpdate)
586-
{
587-
Dictionary<GitFileMetadataName, string> metadata = [];
578+
string dotnetVersion = targetGlobalJson.SelectToken("tools.dotnet")?.ToString();
579+
if (dotnetVersion == null)
580+
{
581+
_logger.LogInformation($"Could not find token `tools.dotnet` in target repo's `{VersionFiles.GlobalJson}`." +
582+
"Skipping dotnet SDK update.");
583+
return null;
584+
}
588585

589-
globalJson["tools"]["dotnet"] = incomingDotnetVersion.ToNormalizedString();
590-
metadata.Add(GitFileMetadataName.ToolsDotNetUpdate, incomingDotnetVersion.ToNormalizedString());
586+
var targetRepoVersion = SemanticVersion.Parse(dotnetVersion);
587+
if (targetRepoVersion.CompareTo(incomingDotnetVersion) > 0)
588+
{
589+
_logger.LogInformation($"The dotnet SDK version in the target repo's `{VersionFiles.GlobalJson}` is higher than the " +
590+
"incoming change. Skipping dotnet SDK update.");
591+
return null;
592+
}
591593

592-
// Also update and keep sdk.version in sync.
593-
JToken sdkVersion = globalJson.SelectToken("sdk.version");
594-
if (sdkVersion != null)
595-
{
596-
globalJson["sdk"]["version"] = incomingDotnetVersion.ToNormalizedString();
597-
metadata.Add(GitFileMetadataName.SdkVersionUpdate, incomingDotnetVersion.ToNormalizedString());
598-
}
594+
Dictionary<GitFileMetadataName, string> metadata = [];
599595

600-
return metadata;
601-
}
602-
}
603-
else
604-
{
605-
_logger.LogError("Could not parse the repo's dotnet version from the global.json. Skipping update to dotnet version sections");
606-
return null;
607-
}
608-
}
609-
catch (Exception ex)
596+
targetGlobalJson["tools"]["dotnet"] = incomingDotnetVersion.ToNormalizedString();
597+
metadata.Add(GitFileMetadataName.ToolsDotNetUpdate, incomingDotnetVersion.ToNormalizedString());
598+
599+
// Also keep sdk.version in sync with tools.dotnet
600+
JToken sdkVersion = targetGlobalJson.SelectToken("sdk.version");
601+
if (sdkVersion != null)
610602
{
611-
_logger.LogError(ex, "Failed to update Dotnet version for global.json. Skipping update to version sections.");
603+
targetGlobalJson["sdk"]["version"] = incomingDotnetVersion.ToNormalizedString();
604+
metadata.Add(GitFileMetadataName.SdkVersionUpdate, incomingDotnetVersion.ToNormalizedString());
612605
}
613606

614-
// No updates
615-
return null;
607+
return metadata;
616608
}
617609

618610
private static bool IsOnlyPresentInMaestroManagedFeed(HashSet<string> locations)

src/Microsoft.DotNet.Darc/DarcLib/Helpers/IDependencyFileManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Task<GitFileContentContainer> UpdateDependencyFiles(
6464
string? branch,
6565
IEnumerable<DependencyDetail> oldDependencies,
6666
SemanticVersion? incomingDotNetSdkVersion,
67-
bool forceGlobalJsonUpdate = false,
6867
bool? repoHasVersionDetailsProps = null);
6968

7069
XmlDocument UpdatePackageSources(XmlDocument nugetConfig, Dictionary<string, HashSet<string>> maestroManagedFeedsByRepo);

src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/BackflowConflictResolver.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ await _vmrVersionFileMerger.MergeJsonAsync(
341341
targetRepo.Path,
342342
branch: null, // reads the working tree
343343
currentRepoDependencies.Dependencies,
344-
targetDotNetVersion,
345-
// make sure that we always backflow the VMRs root global.json sdk version
346-
forceGlobalJsonUpdate: true);
344+
targetDotNetVersion);
347345

348346
// This actually does not commit but stages only
349347
await _libGit2Client.CommitFilesAsync(updatedFiles.GetFilesToCommit(), targetRepo.Path, null, null);

src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/CodeFlowVmrUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public async Task<bool> UpdateRepository(
9494
bool resetToRemoteWhenCloningRepo = false,
9595
CancellationToken cancellationToken = default)
9696
{
97-
await _dependencyTracker.RefreshMetadata();
97+
await _dependencyTracker.RefreshMetadataAsync();
9898

9999
VmrDependencyVersion currentVersion = _dependencyTracker.GetDependencyVersion(mapping)
100100
?? throw new Exception($"Failed to find current version for {mapping.Name}");

src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/CodeflowChangeAnalyzer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ public async Task<bool> ForwardFlowHasMeaningfulChangesAsync(string mappingName,
110110

111111
if (unknownChangedFiles.Any())
112112
{
113-
_logger.LogInformation("Flow contains changes that warrant PR creation: {files}",
114-
string.Join(", ", unknownChangedFiles));
113+
_logger.LogInformation("Flow contains changes that warrant PR creation");
115114
return true;
116115
}
117116

0 commit comments

Comments
 (0)