Skip to content

Commit a440083

Browse files
authored
Fix conflict message when flows are blocked (#5473)
1 parent 3f2f513 commit a440083

File tree

4 files changed

+7
-20
lines changed

4 files changed

+7
-20
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ public class ConflictInPrBranchException : DarcException
6161

6262
public ConflictInPrBranchException(
6363
string failedMergeMessage,
64-
string targetBranch,
65-
string mappingName,
66-
bool isForwardFlow)
67-
: this(ParseResult(failedMergeMessage, mappingName, isForwardFlow), targetBranch)
64+
string targetBranch)
65+
: this(ParseResult(failedMergeMessage), targetBranch)
6866
{
6967
}
7068

@@ -74,7 +72,7 @@ public ConflictInPrBranchException(IReadOnlyCollection<string> conflictedFiles,
7472
ConflictedFiles = conflictedFiles;
7573
}
7674

77-
private static List<string> ParseResult(string failureException, string mappingName, bool isForwardFlow)
75+
private static List<string> ParseResult(string failureException)
7876
{
7977
List<string> filesInConflict = [];
8078
var errors = failureException.Split(Environment.NewLine);
@@ -91,16 +89,7 @@ private static List<string> ParseResult(string failureException, string mappingN
9189
}
9290
}
9391

94-
if (isForwardFlow)
95-
{
96-
// Convert VMR paths to normal repo paths, for example src/repo/file.cs -> file.cs
97-
return [..filesInConflict.Select(file => file.Split('/', 3)[2]).Distinct()];
98-
}
99-
else
100-
{
101-
// If we're backflowing, the file paths are already normalized
102-
return [..filesInConflict.Distinct().Select(file => $"src/{mappingName}/{file}")];
103-
}
92+
return [..filesInConflict.Distinct()];
10493
}
10594
}
10695

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ codeflowOptions with
360360
if (headBranchExisted)
361361
{
362362
_logger.LogInformation("Failed to update a PR branch because of a conflict. Stopping the flow..");
363-
throw new ConflictInPrBranchException(e.Result.StandardError, codeflowOptions.TargetBranch, codeflowOptions.Mapping.Name, isForwardFlow: false);
363+
throw new ConflictInPrBranchException(e.Result.StandardError, codeflowOptions.TargetBranch);
364364
}
365365

366366
// Otherwise, we have a conflicting change in the last backflow PR (before merging)

test/ProductConstructionService.DependencyFlow.Tests/PullRequestUpdaterTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,7 @@ protected void WithForwardFlowConflict(Mock<IRemote> remote, IReadOnlyCollection
586586
? new PatchApplicationLeftConflictsException(conflictedFiles, new NativePath(VmrPath))
587587
: new ConflictInPrBranchException(
588588
"error: patch failed: " + string.Join(Environment.NewLine + "error: patch failed: ", conflictedFiles),
589-
"branch",
590-
"repo",
591-
isForwardFlow: true));
589+
"branch"));
592590
}
593591

594592
protected void AndShouldHavePullRequestCheckReminder(string? url = null)

tools/ProductConstructionService.ReproTool/Operations/Operation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected async Task<Build> CreateBuildAsync(string repositoryUrl, string branch
7979
protected async Task TriggerSubscriptionAsync(string subscriptionId, int buildId = 0)
8080
{
8181
logger.LogInformation("Triggering subscription {subscriptionId}", subscriptionId);
82-
await localPcsApi.Subscriptions.TriggerSubscriptionAsync(buildId, force: false, Guid.Parse(subscriptionId));
82+
await localPcsApi.Subscriptions.TriggerSubscriptionAsync(buildId, force: true, Guid.Parse(subscriptionId));
8383
}
8484

8585
protected async Task<AsyncDisposableValue<string>> PrepareVmrForkAsync(string branch, bool skipCleanup)

0 commit comments

Comments
 (0)