Skip to content

Support darc vmr reset from the source repo#6434

Open
Copilot wants to merge 12 commits into
mainfrom
copilot/support-darc-vmr-reset
Open

Support darc vmr reset from the source repo#6434
Copilot wants to merge 12 commits into
mainfrom
copilot/support-darc-vmr-reset

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

darc vmr reset required an explicit [mapping]:[sha], unlike darc vmr forwardflow, which can infer context from the current source repo. This change aligns reset with that workflow so vmr-sync callers can invoke reset from the repo being synchronized and only provide --vmr.

  • CLI behavior

    • Allow darc vmr reset to omit the positional target when invoked from a source repo.
    • Resolve the mapping from the repo’s eng/Version.Details.xml <Source> tag.
    • Resolve the target revision from the current repo HEAD.
  • Reset execution

    • Add the current repo as an additional remote for the inferred mapping so reset can materialize the current commit into the target VMR.
    • Keep existing explicit [mapping]:[sha], --build, and --channel flows unchanged.
  • Diagnostics

    • Improve the failure path when the current directory is not a git repo or when the repo does not have a usable <Source> tag.
# before
darc vmr reset product-repo1:HEAD --vmr /path/to/vmr

# now
cd /path/to/product-repo1
darc vmr reset --vmr /path/to/vmr

#5973

Copilot AI changed the title [WIP] Support darc vmr reset outside of vmr directory Support darc vmr reset from the source repo Jun 23, 2026
Copilot AI requested a review from dkurepa June 23, 2026 11:04
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot revert all changes to this project

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 195a0dd.

Copilot AI requested a review from dkurepa June 23, 2026 12:44
// Default behavior: Target is in the format [mapping]:[sha]
var parts = _options.Target.Split(':', 2);
if (parts.Length != 2)
currentRepositoryTarget = await TryResolveTargetFromCurrentRepositoryAsync();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot let's flip it around. If target is provided, we use it. If it's not we look if we're in the repo and get the data from it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in aa5b235.

Copilot AI requested a review from dkurepa June 23, 2026 12:54
// When --build or --channel is provided, Target should only be the mapping name
mappingName = _options.Target;

if (string.IsNullOrWhiteSpace(mappingName))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot let's move this check above assigning mappingName the target value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 64b55f8.

Copilot AI requested a review from dkurepa June 23, 2026 13:05
@dkurepa dkurepa marked this pull request as ready for review June 23, 2026 13:20
Copilot AI review requested due to automatic review settings June 23, 2026 13:20

Copilot AI left a comment

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.

Pull request overview

Aligns darc vmr reset with darc vmr forwardflow by allowing reset to infer the target mapping and SHA from the current source repository context (so callers can run reset from the repo being synchronized and pass only --vmr).

Changes:

  • Makes Target positional argument optional for darc vmr reset and documents the inferred-default behavior.
  • Adds inference logic to resolve mapping from eng/Version.Details.xml <Source> and SHA from current repo HEAD when Target is omitted.
  • Adds the current repo path as an additional remote for the inferred mapping so reset can materialize the local commit into the VMR.

Reviewed changes

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

File Description
src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/ResetCommandLineOptions.cs Makes Target optional and updates help text to describe inferred behavior.
src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs Implements target inference from the current repo and injects dependencies to read Version.Details and resolve HEAD SHA; adds an additional remote when inferred.

Comment thread src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/ResetCommandLineOptions.cs Outdated
Comment on lines +305 to +309
catch (Exception ex)
{
_logger.LogDebug(ex, "Could not resolve a git repository root from '{path}'", Environment.CurrentDirectory);
return null;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot replace the logDebug with the suggestion provided in this comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in 79ce0c8.

Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs Outdated
Comment on lines +112 to +117
if (currentRepositoryTarget == null)
{
_logger.LogError(
"Target must be provided as [mapping]:[sha], or the command must be run from a source repository with a VMR Source tag.");
return Constants.ErrorCode;
}
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/ResetCommandLineOptions.cs Outdated
Comment thread src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/ResetOperation.cs Outdated

@adamzip adamzip left a comment

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.

LGTM

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