Opposite flow merged during open pr#5230
Conversation
aa2e9a9 to
838c278
Compare
838c278 to
3ea0c5a
Compare
Co-authored-by: Přemek Vysoký <[email protected]>
Co-authored-by: Přemek Vysoký <[email protected]>
Co-authored-by: Přemek Vysoký <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR implements functionality to handle "opposite flow merged during open PR" scenarios by blocking pull requests from receiving future codeflow updates when conflicting flows have been merged.
Key changes include:
- Added detection logic for when opposite direction flows have been merged while a PR is open
- Implemented PR blocking mechanism with new
BlockingCodeflowExceptionandBlockedFromFutureUpdatesproperty - Enhanced comment system to support template replacements for better user messaging
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| PullRequestUpdater.cs | Refactored code flow execution into separate method and added blocking logic for PRs |
| PullRequestCommenter.cs | Added template replacement functionality for dynamic comment content |
| InProgressPullRequest.cs | Added BlockedFromFutureUpdates property to track blocked PRs |
| VmrCodeflower.cs | Added detection logic for opposite flow scenarios and blocking exception |
| Exceptions.cs | Added new BlockingCodeflowException for codeflow blocking scenarios |
| PcsVmrForwardFlower.cs | Updated constructor to include comment collector dependency |
| PcsVmrBackFlower.cs | Updated constructor to include comment collector dependency |
| VmrForwardFlower.cs | Updated constructor to include comment collector dependency |
| VmrBackflower.cs | Updated constructor to include comment collector dependency |
…ndencyFlow/PullRequestUpdater.cs Co-authored-by: Copilot <[email protected]>
| private readonly ILogger<VmrCodeFlower> _logger; | ||
|
|
||
| private static readonly string CannotFlowAdditionalFlowsInPrMsg = string.Concat( | ||
| "The source repository has received code changes from outside of this PR branch. This PR will stop ", |
There was a problem hiding this comment.
isn't the problem that an opposite direction codeflow was merged?
For example, if we're printing this for a backflow, it means that a forward flow for that repo was merged, causing the next backflow to be considered "opposite direction"
| "PR must be merged or closed. Once this is done, code flows into the repository will resume normally ", | ||
| "on the next subscription trigger. In order to force the subscription trigger, merge or close this PR " + | ||
| "and run the following command using the subscription-id found in this PR. \n", | ||
| "`darc trigger-subscription --id <subscriptionId>`."); |
There was a problem hiding this comment.
think this has to be updated for the force parameter?
There was a problem hiding this comment.
That message is about closing or merging the PR and triggering the subscription normally (no force needed)
There was a problem hiding this comment.
but that is another option, no? if a person wants to trigger another subscription update in the same PR, they can use force
There was a problem hiding this comment.
I think this part of the sentence is problematic:
In order to force the subscription trigger
and then it proceeds to give instructions for re-opening while we have 2 options - force-trigger or re-open
| private static readonly string CannotFlowAdditionalFlowsInPrMsg = string.Concat( | ||
| "The source repository has received code changes from an opposite flow. Any additional codeflows into ", | ||
| "this PR may potentially result in lost changes. Please continue with one of the following options: \n", | ||
| "1. Close or merge this PR and let the codeflow continue normally. \n", | ||
| "2. Close or merge this PR and receive the new codeflow immediately by running ", | ||
| "`darc trigger-subscription --id <subscriptionId>`. \n", | ||
| "3. Keep flowing changes into this PR anyway by force-triggering the subscription: ", | ||
| "`darc trigger-subscription --force --id <subscriptionId>`."); |
There was a problem hiding this comment.
I think the new lines are missing in some of these place. Would it be better to just use a multi-line string?
| private static readonly string CannotFlowAdditionalFlowsInPrMsg = string.Concat( | |
| "The source repository has received code changes from an opposite flow. Any additional codeflows into ", | |
| "this PR may potentially result in lost changes. Please continue with one of the following options: \n", | |
| "1. Close or merge this PR and let the codeflow continue normally. \n", | |
| "2. Close or merge this PR and receive the new codeflow immediately by running ", | |
| "`darc trigger-subscription --id <subscriptionId>`. \n", | |
| "3. Keep flowing changes into this PR anyway by force-triggering the subscription: ", | |
| "`darc trigger-subscription --force --id <subscriptionId>`."); | |
| private static readonly string CannotFlowAdditionalFlowsInPrMsg = | |
| """ | |
| The source repository has received code changes from an opposite flow. Any additional codeflows into | |
| this PR may potentially result in lost changes. | |
| Please continue with one of the following options: | |
| 1. Close or merge this PR and let the codeflow continue normally | |
| 2. Close or merge this PR and receive the new codeflow immediately by running | |
| `darc trigger-subscription --id <subscriptionId>` | |
| 3. Force-flow changes into this PR but at your own risk (some PR commits might be reverted): | |
| `darc trigger-subscription --force --id <subscriptionId>` | |
| """; |
There was a problem hiding this comment.
I think the newlines are in the right place. I avoided multiline string because I didn't want extremely long lines in the editor. Here's what the comment would currently look like on GH:
Important
The source repository has received code changes from an opposite flow. Any additional codeflows into this PR may potentially result in lost changes. Please continue with one of the following options:
- Close or merge this PR and let the codeflow continue normally.
- Close or merge this PR and receive the new codeflow immediately by running
darc trigger-subscription --id <subscriptionId>. - Keep flowing changes into this PR anyway by force-triggering the subscription:
darc trigger-subscription --id <subscriptionId>.
In case of unclarities, consult the FAQ or tag \@dotnet/product-construction for assistance.
There was a problem hiding this comment.
Ah, that looks good.
Mine will look like this:
Important
The source repository has received code changes from an opposite flow. Any additional codeflows into
this PR may potentially result in lost changes.
Please continue with one of the following options:
- Close or merge this PR and let the codeflow continue normally
- Close or merge this PR and receive the new codeflow immediately by running
darc trigger-subscription --id <subscriptionId> - Force-flow changes into this PR but at your own risk (some PR commits might be reverted):
darc trigger-subscription --force --id <subscriptionId>
There was a problem hiding this comment.
Maybe it's more readable without all those \n and ",?
There was a problem hiding this comment.
@adamzip my suggestion also had this part at your own risk (some PR commits might be reverted). Maybe we should keep that?
There was a problem hiding this comment.
I also had the commands on their own line so they are easier to copy (3 mouse clicks)
#5148
Note: still WIP. The refactoring commit actually includes some functional changes - I should clean it up