Skip to content

Fix working tree state after local codeflow operations#5433

Merged
premun merged 6 commits intodotnet:mainfrom
premun:prvysoky/fix-flow-commands
Nov 6, 2025
Merged

Fix working tree state after local codeflow operations#5433
premun merged 6 commits intodotnet:mainfrom
premun:prvysoky/fix-flow-commands

Conversation

@premun
Copy link
Copy Markdown
Member

@premun premun commented Nov 5, 2025

I was adding a test verifying the reverts while using the rebase codeflow operations and found some small problems.
In same direction local flows with conflicts, the working tree was not reset based on index so it didn't have the file updates.

#5362

Copilot AI review requested due to automatic review settings November 5, 2025 15:47
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

catch (PatchApplicationLeftConflictsException e)
{
// We need to make sure that working tree matches the staged changes
await targetRepo.ExecuteGitCommand(["clean", "-xfd"], cancellationToken: cancellationToken);
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.

What exactly is this expecting to clean? Untracked changes that were on the user's environment? Or untracked changes created by the codeflow?

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.

When you have a file that ends up being removed, it will be removed in index but untracked in working tree. So we need to get rid of it this way.

foreach (var file in dirtyFiles)
{
cancellationToken.ThrowIfCancellationRequested();
await targetRepo.CheckoutAsync(file);
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.

Am I missing something? I don't see an overload of CheckoutAsync that takes just a file path.
Why are we expecting uncommitted (or unindexed) changes in files after codeflow?

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 don't see an overload of CheckoutAsync that takes just a file path.

The API is probably named wrong because you can also supply a path and it checks it out from the index.

Why are we expecting uncommitted (or unindexed) changes in files after codeflow?

Same reason as above.

@premun premun merged commit 790bb3f into dotnet:main Nov 6, 2025
8 of 9 checks passed
@premun premun deleted the prvysoky/fix-flow-commands branch November 6, 2025 10:13
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