Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/Maestro/SubscriptionActorService/PullRequestActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,18 @@ await AddDependencyFlowEventsAsync(
MergePolicyCheckResult.PendingPolicies,
pr.Url);

var targetBranchDeps = (await darcRemote.GetDependenciesAsync(targetRepository, targetBranch)).ToList();
var requiredDescriptionUpdates = targetRepositoryUpdates.RequiredUpdates
.Select(requiredUpdates =>
{
requiredUpdates.deps = ReplaceFromDependency(requiredUpdates.deps, targetBranchDeps);

return requiredUpdates;
})
.ToList();

pullRequest.Description = await _pullRequestBuilder.CalculatePRDescriptionAndCommitUpdatesAsync(
targetRepositoryUpdates.RequiredUpdates,
requiredDescriptionUpdates,
pullRequest.Description,
targetRepository,
pullRequest.HeadBranch);
Expand Down Expand Up @@ -1075,6 +1085,20 @@ private async Task<RepositoryBranchUpdate> GetRepositoryBranchUpdate()

private static string GetNewBranchName(string targetBranch) => $"darc-{targetBranch}-{Guid.NewGuid()}";

private static List<DependencyUpdate> ReplaceFromDependency(List<DependencyUpdate> dependencyUpdate, List<DependencyDetail> replaces)
{
return dependencyUpdate
.Select(update =>
{
update.From = replaces
.Where(replace => update.From.Name == replace.Name)
.FirstOrDefault(update.From);

return update;
})
.ToList();
}

#region Code flow subscriptions

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,18 @@ await AddDependencyFlowEventsAsync(
MergePolicyCheckResult.PendingPolicies,
pr.Url);

var targetBranchDeps = (await darcRemote.GetDependenciesAsync(targetRepository, targetBranch)).ToList();
var requiredDescriptionUpdates = targetRepositoryUpdates.RequiredUpdates
.Select(requiredUpdates =>
{
requiredUpdates.deps = ReplaceFromDependency(requiredUpdates.deps, targetBranchDeps);

return requiredUpdates;
})
.ToList();

pullRequest.Description = await _pullRequestBuilder.CalculatePRDescriptionAndCommitUpdatesAsync(
targetRepositoryUpdates.RequiredUpdates,
requiredDescriptionUpdates,
pullRequest.Description,
targetRepository,
pullRequest.HeadBranch);
Expand Down Expand Up @@ -836,6 +846,20 @@ private async Task ClearAllStateAsync()
await _pullRequestUpdateReminders.UnsetReminderAsync();
}

private static List<DependencyUpdate> ReplaceFromDependency(List<DependencyUpdate> dependencyUpdate, List<DependencyDetail> replaces)
{
return dependencyUpdate
.Select(update =>
{
update.From = replaces
.Where(replace => update.From.Name == replace.Name)
.FirstOrDefault(update.From);

return update;
})
.ToList();
}

#region Code flow subscriptions

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion test/Maestro.ScenarioTests/MaestroScenarioTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ protected async Task AddDependenciesToLocalRepo(string repoPath, string name, st
{
using (ChangeDirectory(repoPath))
{
await RunDarcAsync(["add-dependency", "--name", name, "--type", isToolset ? "toolset" : "product", "--repo", repoUri, "--version", "0.0.1"]);
await RunDarcAsync([
"add-dependency", "--name", name, "--version", "0.0.1", "--type", isToolset ? "toolset" : "product", "--repo", repoUri]
);
}
}
protected async Task<string> GetTestChannelsAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ protected async Task AddDependenciesToLocalRepo(string repoPath, List<AssetData>
{
foreach (AssetData asset in dependencies)
{
List<string> parameters = ["add-dependency", "--name", asset.Name, "--type", "product", "--repo", repoUri];
List<string> parameters = [
"add-dependency", "--name", asset.Name,"--type", "product", "--repo", repoUri,
];

if (!string.IsNullOrEmpty(coherentParent))
{
Expand Down