Skip to content

Stop ForwardFlow updates if they'd overwrite manual PR changes#5043

Merged
dkurepa merged 16 commits intodotnet:mainfrom
dkurepa:dkurepa/DontOverwritePRChanges
Jul 11, 2025
Merged

Stop ForwardFlow updates if they'd overwrite manual PR changes#5043
dkurepa merged 16 commits intodotnet:mainfrom
dkurepa:dkurepa/DontOverwritePRChanges

Conversation

@dkurepa
Copy link
Copy Markdown
Member

@dkurepa dkurepa commented Jul 9, 2025

Copilot AI review requested due to automatic review settings July 9, 2025 14:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR prevents forward-flow operations from overwriting manual changes on a pull request by detecting non‐bot commits in the VMR, throwing a dedicated exception, and commenting on the PR before retrying after merge. It also extends the remote Git abstractions to fetch existing PR comments and adds a full scenario test.

  • Introduces ManualChangesWouldGetOverwrittenException and ValidateNothingGetsOverwritten in the VMR flow.
  • Updates PullRequestUpdater to catch the exception, comment the PR, and schedule a retry.
  • Adds GetPullRequestCommentsAsync to remote interfaces and clients, plus a scenario test verifying manual-change protection.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/ProductConstructionService.ScenarioTests/ScenarioTests_CodeFlow.cs Added a new NUnit scenario test for manual‐change protection in forward flow.
test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs Introduced FastForwardAsync helper to fetch and pull the latest in tests.
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs Catches the new exception, implements HandleOverwrittingChanges, and schedules reminders.
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrPatchHandler.cs Added --no-color to Git diff commands.
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs Calls ValidateNothingGetsOverwritten before applying forward flows.
src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/Exceptions.cs Defines ManualChangesWouldGetOverwrittenException.
src/Microsoft.DotNet.Darc/DarcLib/Remote.cs Added GetPullRequestCommentsAsync to fetch existing PR comments.
src/Microsoft.DotNet.Darc/DarcLib/IRemoteGitRepo.cs Declared GetPullRequestCommentsAsync in the remote Git interface.
src/Microsoft.DotNet.Darc/DarcLib/IRemote.cs Added GetPullRequestCommentsAsync to the IRemote interface.
src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs Implemented PR comment retrieval via Octokit.
src/Microsoft.DotNet.Darc/DarcLib/Constants.cs Added DefaultCommitAuthor constant for bot commit filtering.
src/Microsoft.DotNet.Darc/DarcLib/AzureDevOpsClient.cs Implemented PR comment retrieval for Azure DevOps.
Comments suppressed due to low confidence (1)

src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs:1383

  • The method name HandleOverwrittingChanges has a typo. Consider renaming it to HandleOverwritingChanges (single 't') or HandleOverwrittenChanges for clarity.
    private async Task HandleOverwrittingChanges(SubscriptionDTO subscription, List<string> commits, InProgressPullRequest pr, SubscriptionUpdateWorkItem update)

adamzip
adamzip previously approved these changes Jul 10, 2025
Copy link
Copy Markdown
Contributor

@adamzip adamzip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple comments

Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/Exceptions.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs Outdated

// if the first commit in the head branch wasn't made by the bot don't check, we might be in a test
if (headBranchCommits[0].commiter != Constants.DefaultCommitAuthor)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a log here to explain the situation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added logging, but not here. I don't think we need it here, we're just gonna continue in this case. I added logs in the error handling method tho

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking if there's somehow a codeflow PR where the first commit is not maestro bot (for example if someone tried to fix an issue in a codeflow PR by doing a rebase), then it would be nice to know about in the logs. Is it too much of an implausible situation?


// if the first commit in the head branch wasn't made by the bot don't check, we might be in a test
if (headBranchCommits[0].commiter != Constants.DefaultCommitAuthor)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking if there's somehow a codeflow PR where the first commit is not maestro bot (for example if someone tried to fix an issue in a codeflow PR by doing a rebase), then it would be nice to know about in the logs. Is it too much of an implausible situation?

@dkurepa
Copy link
Copy Markdown
Member Author

dkurepa commented Jul 11, 2025

I was thinking if there's somehow a codeflow PR where the first commit is not maestro bot (for example if someone tried to fix an issue in a codeflow PR by doing a rebase), then it would be nice to know about in the logs. Is it too much of an implausible situation?

Ah I get it, but I don't think that should ever happen? especially with the codeflow PRs, might bring something else along with it. I'll merge this as is for now, we can maybe explore that option when we work on the real implementation

@dkurepa dkurepa merged commit 2e55418 into dotnet:main Jul 11, 2025
9 checks passed
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jul 15, 2025
…t#5043)

<!-- Link the GitHub or AzDO issue this pull request is associated with.
Please copy and paste the full URL rather than using the
dotnet/arcade-services# syntax -->
dotnet#5030

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Adam <[email protected]>
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jul 15, 2025
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jul 15, 2025
…t#5043)

<!-- Link the GitHub or AzDO issue this pull request is associated with.
Please copy and paste the full URL rather than using the
dotnet/arcade-services# syntax -->
dotnet#5030

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Adam <[email protected]>
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jul 15, 2025
Stop ForwardFlow updates if they'd overwrite manual PR changes (dotnet#5043)
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants