Skip to content

Conversation

@dkurepa
Copy link
Member

@dkurepa dkurepa commented Dec 8, 2025

Copilot AI review requested due to automatic review settings December 8, 2025 06:53
@dkurepa dkurepa changed the title start Make darc add-subscriptiojn work with the new config repo Dec 8, 2025
Copy link
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 implements the initial infrastructure for managing subscriptions via a configuration repository rather than through the database. It introduces a new ConfigurationManagementOperation base class that enables DARC commands to read from and commit to a Git-based configuration repository, with support for both local and remote repositories (GitHub and Azure DevOps).

Key changes:

  • New ConfigurationManagementOperation base class provides common functionality for managing YAML configuration files in a Git repository
  • Extended Git clients to support direct API commits without cloning (GitHub and Azure DevOps)
  • Added IsEquivalentTo method to SubscriptionYaml for duplicate detection
  • Updated subscription operations to inherit from ConfigurationManagementOperation

Reviewed changes

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

Show a summary per file
File Description
src/Microsoft.DotNet.Darc/DarcLib/RemoteRepoBase.cs Removed obsolete logger parameter from documentation
src/Microsoft.DotNet.Darc/DarcLib/Remote.cs Added wrapper method for no-cloning commit functionality
src/Microsoft.DotNet.Darc/DarcLib/Models/Yaml/SubscriptionYaml.cs Implemented equivalence checking for subscription deduplication
src/Microsoft.DotNet.Darc/DarcLib/LocalLibGit2Client.cs Added repository existence check method
src/Microsoft.DotNet.Darc/DarcLib/LocalGitClient.cs Added branch existence check and branch creation from base
src/Microsoft.DotNet.Darc/DarcLib/IRemoteGitRepo.cs Moved common methods to IGitRepo and added CommitFilesWithNoCloningAsync
src/Microsoft.DotNet.Darc/DarcLib/IRemote.cs Added interface method for no-cloning commits
src/Microsoft.DotNet.Darc/DarcLib/IGitRepo.cs Moved branch and repository management methods from IRemoteGitRepo
src/Microsoft.DotNet.Darc/DarcLib/GitHubClient.cs Implemented direct API-based commit functionality using GitHub Git Data API
src/Microsoft.DotNet.Darc/DarcLib/AzureDevOpsClient.cs Implemented direct API-based commit functionality using Azure DevOps pushes API
src/Microsoft.DotNet.Darc/Darc/Options/SubscriptionCommandLineOptions.cs Changed base class to ConfigurationManagementCommandLineOptions
src/Microsoft.DotNet.Darc/Darc/Options/ConfigurationManagementCommandLineOptions.cs New options class for configuration repository management
src/Microsoft.DotNet.Darc/Darc/Options/CommandLineOptions.cs Registered LocalGitRepoFactory and LocalGitClient in DI container
src/Microsoft.DotNet.Darc/Darc/Operations/UpdateSubscriptionOperation.cs Updated constructor to use ConfigurationManagementOperation base
src/Microsoft.DotNet.Darc/Darc/Operations/SubscriptionOperationBase.cs Changed base class to ConfigurationManagementOperation
src/Microsoft.DotNet.Darc/Darc/Operations/ConfigurationManagementOperation.cs New base class providing configuration repository management functionality
src/Microsoft.DotNet.Darc/Darc/Operations/AddSubscriptionOperation.cs Added configuration repository support with duplicate detection
src/Microsoft.DotNet.Darc/Darc/Microsoft.DotNet.Darc.csproj Added dependency on Microsoft.DotNet.MaestroConfiguration.Client
eng/Version.Details.xml Updated MaestroConfiguration.Client package version
eng/Version.Details.props Updated MaestroConfiguration.Client package version

@dkurepa dkurepa changed the title Make darc add-subscriptiojn work with the new config repo Make darc add-subscription work with the new config repo Dec 8, 2025
premun
premun previously approved these changes Dec 9, 2025
premun
premun previously approved these changes Dec 9, 2025
@premun
Copy link
Member

premun commented Dec 9, 2025

@dkurepa do you have a task for updating of Darc.md after we're done?

Ideally we'd maybe scrap the whole file as the whole format is just useless and we'd:

  • explain the main commands in some short concise way
  • explain the configuration repo interaction

@dkurepa
Copy link
Member Author

dkurepa commented Dec 9, 2025

@dkurepa do you have a task for updating of Darc.md after we're done?

Ideally we'd maybe scrap the whole file as the whole format is just useless and we'd:

  • explain the main commands in some short concise way
  • explain the configuration repo interaction

It's under the Fully transition issue currently #5537, will probably end up splitting that one into multiple

@premun
Copy link
Member

premun commented Dec 9, 2025

@dkurepa if you're going to spin up the AI tasks for other commands then don't. Matt has a request which might mean a change to the code here that the AI will be reusing

}

subscriptionsInFile.Add(subscriptionYaml);
await WriteConfigurationDataAsync(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await WriteConfigurationDataAsync(
await CommitConfigurationChangesAsync(


if (!await _configurationRepo.Value.DoesBranchExistAsync(_options.ConfigurationRepository, _options.ConfigurationBaseBranch))
{
throw new ArgumentException($"The configuration base branch '{_options.ConfigurationBaseBranch}' does not exist in the repository '{_options.ConfigurationRepository}'.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that error message is only true if the repo is remote. With a local one, it could just be that the branch (eg, "prod") hasn't been fetched?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean it still doesn't exist on your repo locally, it's up to the user to figure it out at that point

{
if (!await _configurationRepo.Value.RepoExistsAsync(_options.ConfigurationRepository))
{
throw new ArgumentException($"The configuration repository '{_options.ConfigurationRepository}' is not a valid git repository.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
throw new ArgumentException($"The configuration repository '{_options.ConfigurationRepository}' is not a valid git repository.");
throw new ArgumentException($"ConfigurationRepository must be a valid URI to a remote git repository, or a path to a git repository on disk.");

sourceEnabled: subscriptionYaml.SourceEnabled,
sourceDirectory: subscriptionYaml.SourceDirectory,
targetDirectory: subscriptionYaml.TargetDirectory))
.FirstOrDefault(s => s.TargetBranch == subscriptionYaml.TargetBranch);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: targetBranch could be added to the optional params that GetSubscriptionsAsync accepts

Copy link
Member Author

@dkurepa dkurepa Dec 10, 2025

Choose a reason for hiding this comment

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

ah you mean expand the method

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at it, I wouldn't want to add it as a last argument, but adding it somewhere in the middle would make it so I'd have to check a lot of places, which I wouldn't want to do in this PR

Copy link
Member

@premun premun Dec 10, 2025

Choose a reason for hiding this comment

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

@dkurepa not saying you should add it but in case you are doing such a change in future, VS allows you to add a new param in the "Change signature" modal dialog and you can set what value you want to insert in all calling places. So you'd put something like TODO and it will make sure it's everywhere and you don't break stuff

if (!_options.NoPr)
{
await CreatePullRequest(
$"Add new subscription ({subscriptionYaml.Channel}) {subscriptionYaml.SourceRepository} => {subscriptionYaml.TargetRepository} ({subscriptionYaml.TargetBranch})");
Copy link
Member

Choose a reason for hiding this comment

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

The title could be generated by SubscriptionDescriptionHelper

namespace Microsoft.DotNet.DarcLib.ConfigurationRepository;

// this is just a temporary thing, till we add it in the configuration repo
public class ConfigurationRepositoryOperationParameters
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

@dkurepa dkurepa Dec 10, 2025

Choose a reason for hiding this comment

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

I haven't merged the PR in the config repo yet, so yes

Copy link
Member

Choose a reason for hiding this comment

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

Should we just merge it and tomorrow morning we can use the real interfaces?

Copy link
Member Author

Choose a reason for hiding this comment

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

if this PR looks good to you, could we merge it first, and merge the config repo one tomorrow?

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