Skip to content

Conversation

@dkurepa
Copy link
Member

@dkurepa dkurepa commented Dec 16, 2025

Copilot AI review requested due to automatic review settings December 16, 2025 16:50
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 support for updating subscriptions through the configuration repository (YAML-based approach) in the darc update-subscription command, addressing issue #5512. Previously, subscription updates only went through the BAR API client; now they can also be routed through the configuration repository when the appropriate flag is set.

Key Changes:

  • Added configuration repository support to UpdateSubscriptionOperation with conditional routing based on ShouldUseConfigurationRepository
  • Refactored duplicate subscription validation logic into a shared base class method
  • Implemented the UpdateSubscriptionAsync method in ConfigurationRepositoryManager (was previously throwing NotImplementedException)

Reviewed changes

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

File Description
UpdateSubscriptionOperation.cs Added config repo manager dependency and conditional logic to route updates through config repo or BAR API based on options
SubscriptionOperationBase.cs Added config repo manager field to base class and extracted duplicate validation logic into shared method
AddSubscriptionOperation.cs Refactored to use shared validation method and config repo manager from base class
ConfigurationRepositoryManager.cs Implemented UpdateSubscriptionAsync method and changed DeleteSubscriptionAsync to throw exception instead of logging warning

triggerAutomatically = UxHelpers.PromptForYesNo("Trigger this subscription immediately?");
}
Id = subscription.Id,
Enabled = subscriptionToUpdate.Enabled ?? false,
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The fallback to false may incorrectly disable a subscription if subscriptionToUpdate.Enabled is null but the original subscription was enabled. Consider using subscriptionToUpdate.Enabled ?? subscription.Enabled to preserve the existing state when no update is specified.

Suggested change
Enabled = subscriptionToUpdate.Enabled ?? false,
Enabled = subscriptionToUpdate.Enabled ?? subscription.Enabled,

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +191
subscriptionsInFile.Remove(existingSubscription);
subscriptionsInFile.Add(updatedSubscription);
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

Rather than removing and adding, consider replacing the subscription in place to maintain the original list order. This can be done by finding the index and replacing at that position: var index = subscriptionsInFile.IndexOf(existingSubscription); subscriptionsInFile[index] = updatedSubscription;

Suggested change
subscriptionsInFile.Remove(existingSubscription);
subscriptionsInFile.Add(updatedSubscription);
var index = subscriptionsInFile.IndexOf(existingSubscription);
subscriptionsInFile[index] = updatedSubscription;

Copilot uses AI. Check for mistakes.
targetDirectory: subscriptionYaml.TargetDirectory))
.FirstOrDefault(s => s.TargetBranch == subscriptionYaml.TargetBranch);

if (equivalentSub?.Id != null && equivalentSub.Id != subscriptionYaml.Id)
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The null check equivalentSub?.Id != null is redundant since FirstOrDefault would return null if no subscription is found, and you can check equivalentSub != null directly. Simplify to: if (equivalentSub != null && equivalentSub.Id != subscriptionYaml.Id)

Suggested change
if (equivalentSub?.Id != null && equivalentSub.Id != subscriptionYaml.Id)
if (equivalentSub != null && equivalentSub.Id != subscriptionYaml.Id)

Copilot uses AI. Check for mistakes.
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.

1 participant