Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Adds explicit commands for adding/removing repositories from the VMR. Previously, users had to use the less discoverable initialize command for additions, and removal required manual manipulation of VMR files.

Changes

New Commands:

  • darc vmr add-repo - Aliases existing IVmrInitializer functionality for better discoverability
  • darc vmr remove-repo - New command that removes repos from VMR

Implementation:

  • Created IVmrRemover interface and VmrRemover implementation extending VmrManagerBase
  • Both commands use hardcoded settings for consistency: TpnTemplate = THIRD-PARTY-NOTICES.txt, GenerateCodeowners = false, GenerateCredScanSuppressions = true
  • add-repo uses default source-mappings path from VmrInfo.DefaultRelativeSourceMappingsPath
  • Removal updates: source manifest, source directories, and regenerates TPN and CredScanSuppressions
  • Both commands registered in VMR subcommand group

Usage:

# Add a repository (uses default source-mappings.json from src/ directory)
darc vmr add-repo runtime:main

# Remove a repository
darc vmr remove-repo runtime

The initialize command remains for backward compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create darc vmr add-repo and darc vmr remove-repo commands</issue_title>
<issue_description>To facilitate changing the VMR to include more repos (e.g. adding something into a feature band), or removal (initializing a feature band by removing shared components), it is necessary to have add and remove commands. There is sort of an add command today (initialize), but no remove.

Recommended course of action is to make darc vmr initialize into add-repo. However, if initialize does more than add a repo, then it should be retained and add-repo would added to the vmr command set. In addition, a remove-repo would also be created.

The commands should update all files that are involved in a repo being in the VMR, with one notable exception

  • Source mappings
  • source manifest
  • cred scan suppressoins
  • 3rd party notices
  • src/
  • Exception: Repo projects - If a repo project is present in the repo, remove should NOT remove it. The repo project tends to have a bit of non-mechanically creatable logic. However, on add, if a repo project is missing, one should be created. This file should just be a barebones <Project Sdk="Microsoft.Build.NoTargets"> project.

Additional notes:

  • When adding a specific sha and remote of the source repo given to do initial population of sources.
  • Changes should be staged locally
  • The add command should accept these arguments:
    • Remote URI - required
    • Commit SHA - required
    • List of file exclusions (optional)
  • The remove command should accept repository (mapping) name</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add darc vmr add-repo and remove-repo commands Add darc vmr add-repo and remove-repo commands Oct 30, 2025
Copilot AI requested a review from premun October 30, 2025 14:53
Copilot finished work on behalf of premun October 30, 2025 14:53
Comment on lines 28 to 35
[Option("tpn-template", Required = false, HelpText = "Path to a template for generating VMRs THIRD-PARTY-NOTICES file. Leave empty to skip generation.")]
public string TpnTemplate { get; set; }

[Option("generate-codeowners", Required = false, HelpText = "Generate a common CODEOWNERS file for all repositories.")]
public bool GenerateCodeowners { get; set; } = false;

[Option("generate-credscansuppressions", Required = false, HelpText = "Generate a common .config/CredScanSuppressions.json file for all repositories.")]
public bool GenerateCredScanSuppressions { get; set; } = false;
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove these. The settings should be hardcoded to:

  • TpnTemplate to VmrInfo.ThirdPartyNoticesFileName
  • GenerateCodeowners to false
  • GenerateCredScanSuppressions to true

Copy link
Member

Choose a reason for hiding this comment

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

Same for the removal command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed all optional parameters and hardcoded the settings as requested. (2603e44)

Comment on lines 17 to 21
[Option("additional-remotes", Required = false, HelpText =
"List of additional remote URIs to add to mappings in the format [mapping name]:[remote URI]. " +
"Example: installer:https://github.com/myfork/installer sdk:/local/path/to/sdk")]
[RedactFromLogging]
public IEnumerable<string> AdditionalRemotes { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed additional-remotes option. (2603e44)

Comment on lines 14 to 15
[Option("source-mappings", Required = true, HelpText = $"A path to the {VmrInfo.SourceMappingsFileName} file to be used for syncing.")]
public string SourceMappings { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@copilot this one, the default path from VmrInfo should be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed source-mappings option and now using default path from VmrInfo. (2603e44)

Comment on lines 16 to 18
[Option("additional-remotes", Required = false, Hidden = true)]
[RedactFromLogging]
public IEnumerable<string> AdditionalRemotes { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed additional-remotes option. (2603e44)

Comment on lines 152 to 169
private async Task RegenerateThirdPartyNoticesAsync(string templatePath, CancellationToken cancellationToken)
{
_logger.LogInformation("Regenerating third-party notices");
await _thirdPartyNoticesGenerator.UpdateThirdPartyNotices(templatePath);
await _localGitClient.StageAsync(_vmrInfo.VmrPath, new[] { VmrInfo.ThirdPartyNoticesFileName }, cancellationToken);
}

private async Task RegenerateCodeownersAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Regenerating CODEOWNERS");
await _codeownersGenerator.UpdateCodeowners(cancellationToken);
}

private async Task RegenerateCredScanSuppressionsAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Regenerating credential scan suppressions");
await _credScanSuppressionsGenerator.UpdateCredScanSuppressions(cancellationToken);
}
Copy link
Member

Choose a reason for hiding this comment

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

@copilot Do not define these as methods but call them directly and remove the logging which is inside of the methods (or should be).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Inlined all three methods and removed the extra logging. (2603e44)

Comment on lines 147 to 150
private string PrepareCommitMessage(string template, string repoName)
{
return template.Replace("{name}", repoName);
}
Copy link
Member

Choose a reason for hiding this comment

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

@copilot Inline this too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Inlined PrepareCommitMessage. (2603e44)

Copilot AI requested a review from premun October 30, 2025 15:05
Copilot finished work on behalf of premun October 30, 2025 15:05
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.

Create darc vmr add-repo and darc vmr remove-repo commands

2 participants