Repository navigation
Block recreation flow when we try to do it on opposite direction flow - #6889
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical guard gap still allows fresh-PR replay to revert target-only fixes during unrelated patch conflicts, and existing tests bypass or inject the guard rather than verify its protection.
2 open issues
What changed in this PR
This PR addresses #6822 by blocking opposite-direction flow recreation during existing PR updates, aiming to prevent conflict recovery from overwriting target-only changes.
Changes:
- Adds a blocking exception and recreation guard, with force/unsafe overrides.
- Updates blocked-flow notifications to explain the risk of reverting target-branch changes.
- Adds updater tests for blocking exceptions and adjusts notification tests.
Codeflow tests were not run in this review environment; please run dotnet test test/Darc/Microsoft.DotNet.DarcLib.Codeflow.Tests.
| File | Description |
|---|---|
test/ProductConstructionService/ProductConstructionService.DependencyFlow.Tests/PullRequestUpdaterTests.cs |
Adds a blocking-exception mock helper and updates notification matching. |
test/ProductConstructionService/ProductConstructionService.DependencyFlow.Tests/PullRequestCommenterTests.cs |
Updates duplicate-comment checks for the new notification. |
test/ProductConstructionService/ProductConstructionService.DependencyFlow.Tests/PendingCodeFlowUpdatesTests.cs |
Tests blocked PR state and outcomes for both exception types. |
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdaters/CodeFlowPullRequestUpdater.cs |
Uses the generalized blocked-flow notification. |
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestCommentBuilder.cs |
Explains recreation risks and expands the force-update warning. |
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrCodeflower.cs |
Guards opposite-direction recreation for existing PR branches. |
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/Exceptions.cs |
Defines the blocking exception for opposite-direction recreation. |
Review effort: Balanced
| // Replaying an opposite-direction flow on top of an existing PR branch replaces the target with a snapshot | ||
| // of the source, which can overwrite changes that haven't been flown yet. We only allow it for unsafe or forced flows. | ||
| if (previousFlows.LastFlow.IsBackflow != currentIsBackflow | ||
| && headBranchExisted |
There was a problem hiding this comment.
this way a PR always gets created. I wonder if we should not create it instead and see it as a failed workitem and deal with it
| public const string OppositeCodeflowMergedNotificationIntro = | ||
| "While this PR was open, the source repository has received code changes from this repository (an opposite codeflow merged)."; | ||
| public const string BlockedCodeflowNotificationIntro = | ||
| "This PR cannot receive new codeflow updates because an opposite-direction codeflow has merged or would need to be recreated."; |
There was a problem hiding this comment.
I think people generally don't understand what means to "recreate a flow".
Instead we should communicate out that a previous flow in the opposite direction has gotten amidst of a conflict.
There was a problem hiding this comment.
ah sorry, I created this PR from a branch in the source repo, not the fork, but then pushed cr changes to the fork
…ndencyFlow/PullRequestCommentBuilder.cs Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>
…creationFlow' into dkurepa/BlockOppositeDirectionRecreationFlow


#6822