Skip to content

Fix re-use of existing clones#5315

Merged
premun merged 5 commits intodotnet:mainfrom
premun:prvysoky/fix-cloning
Sep 29, 2025
Merged

Fix re-use of existing clones#5315
premun merged 5 commits intodotnet:mainfrom
premun:prvysoky/fix-cloning

Conversation

@premun
Copy link
Copy Markdown
Member

@premun premun commented Sep 29, 2025

I found 2 problems in how we handle cloning:

  • PcsVmrBackflower has its own PrepareRepoAndVmr which is almost the same as VmrBackflower except it does not check out the SHA of the last flow correctly. I guess we do check it out later somewhere because otherwise I don't know how this would work.
  • When calling darc vmr backflow, we might end up cloning the repo into TMP instead of properly using the one the user is targeting with the command. Then we fetch the needed commits into the TMP one and fail to find the commits later in the one the user specified.

#5312

When a clone already exists (e.g. during `darc` commands), we incorrectly cloned the repository again to `tmp/`.

The `PcsVmrBackflower` also duplicated some logic from the base class.
Copilot AI review requested due to automatic review settings September 29, 2025 09:33
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 fixes the issue where existing repository clones were not properly reused during darc commands, causing the system to incorrectly create new clones in temporary directories. The fix ensures that the folder path passed to the CloneManager is always used when available.

Key changes:

  • Modified the VmrBackflower base class to accept a target repository path parameter and use it when preparing clones
  • Removed duplicated logic from PcsVmrBackflower by leveraging the base class implementation
  • Added a new method to CloneManager to support using existing clone paths

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
PcsVmrBackFlower.cs Simplified by removing duplicated PrepareVmrAndRepo method and using base class implementation
MaestroAuthTestRepositoryExtensions.cs Refactored to eliminate code duplication and added new PrepareCloneAsync overload
VmrBackflower.cs Enhanced PrepareVmrAndRepo to accept targetRepoPath parameter and use existing clones when available
RepositoryCloneManager.cs Added new interface method and implementation for preparing clones with existing paths
CloneManager.cs Added protected method to handle clone preparation with existing paths

Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrBackflower.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrBackflower.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/CloneManager.cs
@premun
Copy link
Copy Markdown
Member Author

premun commented Sep 29, 2025

I should add unit tests

adamzip
adamzip previously approved these changes Sep 29, 2025
Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrBackflower.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrBackflower.cs Outdated
@premun premun merged commit 5a975d5 into dotnet:main Sep 29, 2025
9 checks passed
@premun premun deleted the prvysoky/fix-cloning branch September 29, 2025 11:08
premun added a commit to premun/arcade-services that referenced this pull request Sep 29, 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.

3 participants