Conversation
Co-authored-by: dkurepa <[email protected]>
Co-authored-by: dkurepa <[email protected]>
Co-authored-by: dkurepa <[email protected]>
|
@copilot rather than rewriting the update logic, you can set the |
Instead of duplicating the update logic, the subscription parameter now populates the options (channel, source repo, target directory, excluded assets) and lets the existing code path handle the update. This is cleaner and maintains consistency with the rest of the codebase. Changes: - Renamed UpdateDependenciesFromSubscriptionAsync to PopulateOptionsFromSubscriptionAsync - Removed duplicate update logic (build selection, dependency filtering, coherency updates) - Set _options properties from subscription metadata and let existing code handle updates - Reduced code by ~93 lines while maintaining all functionality Co-authored-by: dkurepa <[email protected]>
Good point! I've refactored the implementation to populate the |
| if (!string.IsNullOrEmpty(_options.Channel)) | ||
| { | ||
| _logger.LogError("The --subscription parameter cannot be used with --channel. The subscription already specifies a channel."); | ||
| return Constants.ErrorCode; |
There was a problem hiding this comment.
just throw, no need for an error code
There was a problem hiding this comment.
Done. Changed to throw DarcException instead of returning error codes. See commit c6a9b8f.
| _options.ExcludedAssets = string.Join(";", subscription.ExcludedAssets); | ||
| } | ||
|
|
||
| return Constants.SuccessCode; |
There was a problem hiding this comment.
@copilot you're missing the build here. Based on the source repo and the channel, you need to find the latest build from the repo in the channel, and set the BARBuildId parameter to it
There was a problem hiding this comment.
Added the logic to fetch the latest build from the source repository on the channel and set BARBuildId. See commit c6a9b8f.
- Changed validation errors to throw DarcException instead of returning error codes - Added logic to fetch the latest build from source repository on the channel - Set BARBuildId option to use the specific build instead of channel-wide search - This ensures the subscription simulates exactly what Maestro would do Co-authored-by: dkurepa <[email protected]>
| /// Fetch subscription metadata and populate command options based on subscription settings. | ||
| /// This allows the subscription to be simulated using the existing update logic. | ||
| /// </summary> | ||
| private async Task<int> PopulateOptionsFromSubscriptionAsync() |
There was a problem hiding this comment.
@copilot this method should just return a Task then, no need for the status code, and then in the code above you don't have to check
There was a problem hiding this comment.
Done. Changed the return type to Task and removed the status code checking. See commit 3f8e5a2.
Since the method now throws exceptions instead of returning error codes, there's no need to return a status code. Changed the return type from Task<int> to Task and removed the status code checking in the caller. Co-authored-by: dkurepa <[email protected]>
| Subscription subscription; | ||
| try | ||
| { | ||
| subscription = await _barClient.GetSubscriptionAsync(subscriptionId); |
There was a problem hiding this comment.
@copilot we should check if the subscription is source enabled, if it is, throw
There was a problem hiding this comment.
Added check to reject source-enabled subscriptions. See commit 7a8c4d5.
…and check for source-enabled subscriptions - Changed warnings for --target-directory and --excluded-assets to throw exceptions (consistent with other parameter conflicts) - Added check to reject source-enabled subscriptions (VMR code flow) as they are not supported - All parameter conflicts now throw DarcException consistently Co-authored-by: dkurepa <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR adds a --subscription parameter to the darc update-dependencies command that enables users to locally simulate the effect of a specific Maestro subscription. This makes debugging and validating dependency updates easier by allowing developers to test what a subscription would do before it runs automatically.
Key changes:
- Adds subscription ID parameter and validation logic to simulate dependency updates locally
- Implements comprehensive parameter conflict validation and subscription metadata fetching
- Updates documentation with usage examples and scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Microsoft.DotNet.Darc/Darc/Options/UpdateDependenciesCommandLineOptions.cs |
Adds the new SubscriptionId command-line option |
src/Microsoft.DotNet.Darc/Darc/Operations/UpdateDependenciesOperation.cs |
Implements the core subscription simulation logic with validation and metadata fetching |
docs/Darc.md |
Documents the new subscription simulation feature with examples and usage guidelines |
| if (!string.IsNullOrEmpty(_options.Name) && !string.IsNullOrEmpty(_options.Version)) | ||
| { | ||
| throw new DarcException("The --subscription parameter cannot be used with --name and --version. The subscription determines which dependencies to update."); |
There was a problem hiding this comment.
The validation logic is incorrect. This should use OR (||) instead of AND (&&) because --subscription conflicts with either --name OR --version individually, not just when both are present together.
| if (!string.IsNullOrEmpty(_options.Name) && !string.IsNullOrEmpty(_options.Version)) | |
| { | |
| throw new DarcException("The --subscription parameter cannot be used with --name and --version. The subscription determines which dependencies to update."); | |
| if (!string.IsNullOrEmpty(_options.Name) || !string.IsNullOrEmpty(_options.Version)) | |
| { | |
| throw new DarcException("The --subscription parameter cannot be used with --name or --version. The subscription determines which dependencies to update."); |
| if (!string.IsNullOrEmpty(_options.Name) && !string.IsNullOrEmpty(_options.Version)) | ||
| { | ||
| throw new DarcException("The --subscription parameter cannot be used with --name and --version. The subscription determines which dependencies to update."); |
There was a problem hiding this comment.
The error message mentions both --name and --version but the validation only triggers when both are present. The message should clarify that neither parameter can be used individually with --subscription.
| if (!string.IsNullOrEmpty(_options.Name) && !string.IsNullOrEmpty(_options.Version)) | |
| { | |
| throw new DarcException("The --subscription parameter cannot be used with --name and --version. The subscription determines which dependencies to update."); | |
| if (!string.IsNullOrEmpty(_options.Name) || !string.IsNullOrEmpty(_options.Version)) | |
| { | |
| throw new DarcException("The --subscription parameter cannot be used with --name or --version. The subscription determines which dependencies to update."); |
premun
left a comment
There was a problem hiding this comment.
I think we should allow some properties to be passed which will override the subscription data like the build ID
…eration.cs Co-authored-by: Přemek Vysoký <[email protected]>
…eration.cs Co-authored-by: Přemek Vysoký <[email protected]>
- Removed validation that blocked --id (BARBuildId) parameter - Removed validation that blocked --excluded-assets parameter - If --id is provided, use it instead of fetching latest build - If --excluded-assets is provided, use it instead of subscription's excluded assets - Always set TargetDirectory from subscription (removed unnecessary if check) - This allows users to test subscription with different builds or asset filters Co-authored-by: dkurepa <[email protected]>
Summary
Adds a
--subscriptionparameter to thedarc update-dependenciescommand that enables users to locally simulate the effect of a specific Maestro subscription. This makes it easier to debug, validate, and reason about dependency updates as they would occur in Maestro.Fixes #2540
Implementation Approach
The implementation fetches subscription metadata from BAR and populates the command options based on the subscription settings (channel, source repository, target directory, excluded assets). It also fetches the latest build from the source repository on the subscription's channel (unless a build ID is provided), and uses that specific build ID. This allows the existing update logic to handle the dependency updates, ensuring consistency and reducing code duplication.
Changes
New Functionality
When using
--subscription <maestro-subscription-id>, the command now:--idis provided)--idcan be provided to use a specific build instead of the latest--excluded-assetscan be provided to override subscription's excluded assetsValidation
The implementation includes comprehensive validation - all throw
DarcExceptionconsistently:--channel,--packages-folder,--name/--version,--source-repo,--coherency-only,--target-directory--id(to override build),--excluded-assets(to override filters)Example Usage
Example output:
Documentation
Added comprehensive documentation to
docs/Darc.md:Testing
Architecture
The implementation follows the feedback to reuse existing code rather than duplicating logic. The
PopulateOptionsFromSubscriptionAsyncmethod:_optionswith subscription settings and build ID (respecting any overrides)This approach ensures consistency with the rest of the codebase and reduces maintenance burden while allowing flexibility through parameter overrides.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.