Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 20, 2025

Summary

This PR adds support for the --subscription and --excluded-assets arguments to darc vmr forwardflow and darc vmr backflow operations, allowing users to simulate subscription behavior for VMR code flow operations. This brings consistency with the existing darc update-dependencies --subscription functionality.

Problem

Previously, when running VMR codeflow operations, there was no way to simulate how a subscription would behave. Additionally, excluded assets from subscriptions were not being utilized (left as empty arrays), as indicated by TODO comments in the code referencing issue #5313.

Solution

Added subscription support to the codeflow operations by:

  1. Adding --subscription option to CodeFlowCommandLineOptions (shared by both forwardflow and backflow)
  2. Adding --excluded-assets option to CodeFlowCommandLineOptions that can be used standalone or to override subscription's excluded assets
  3. Implementing subscription metadata fetching in CodeFlowOperation base class that:
    • Validates the subscription ID and ensures it's source-enabled (VMR codeflow)
    • Fetches subscription metadata from the Build Asset Registry (BAR)
    • Extracts excluded assets from the subscription and stores them in _options.ExcludedAssets (can be overridden by command-line argument)
    • Determines the latest build from the subscription's source repository and channel (or uses a specific build if --build is provided)
    • Sets the build ID automatically for the codeflow operation
  4. Storing excluded assets in options instead of passing them as method parameters, following the same pattern as other options like --build
  5. Adding comprehensive validation to prevent conflicting options (only --subscription with --ref is prevented; --build and --excluded-assets can be used with --subscription)

Usage

# Forward flow using a subscription (uses latest build and subscription's excluded assets)
darc vmr forwardflow --subscription 12345678-1234-1234-1234-123456789abc /path/to/vmr

# Backflow using a subscription with a specific build
darc vmr backflow --subscription 12345678-1234-1234-1234-123456789abc --build 12345 /path/to/repo

# Forward flow with custom excluded assets (overrides subscription's excluded assets)
darc vmr forwardflow --subscription 12345678-1234-1234-1234-123456789abc --excluded-assets "System.Text.*;Newtonsoft.*" /path/to/vmr

# Forward flow with excluded assets only (no subscription)
darc vmr forwardflow --excluded-assets "System.Text.*;Newtonsoft.*" /path/to/vmr

When --subscription is provided, the tool automatically:

  • Fetches subscription metadata from BAR
  • Uses the latest build from the subscription's channel (unless --build is specified)
  • Applies the subscription's excluded assets during the flow (unless --excluded-assets is specified)
  • Logs subscription details for visibility

Benefits

  • Easier Testing: Users can test subscription behavior without triggering actual subscription runs
  • Better Debugging: Simplifies debugging subscription issues by allowing manual reproduction
  • Flexible Build Selection: Allows combining --subscription with --build to use a specific build with the subscription's excluded assets
  • Flexible Asset Exclusion: Allows combining --subscription with --excluded-assets to override subscription settings, or use --excluded-assets independently
  • Proper Asset Exclusion: Subscription excluded assets are now properly utilized instead of being ignored
  • Consistency: Provides consistent behavior with darc update-dependencies --subscription, where options can be overridden via command-line arguments

Changes

  • Modified 4 files
  • All existing tests pass (117 passed, 1 skipped)
  • No breaking changes

Fixes #5313

Original prompt

This section details on the original issue you should resolve

<issue_title>Support --subscription argument in darc vmr codeflow operations</issue_title>
<issue_description>Similar to #5342 where darc update-dependencies got support for subscription ID to simulate what a subscription would do, we should have the same for the darc vmr forwardflow and darc vmr backflow operations.

The subscription metadata could then be used in other places like excluded assets which we are currently leaving empty.</issue_description>

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

Fixes #5388


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Add support for --subscription argument in darc vmr operations Support --subscription argument in darc vmr codeflow operations Oct 20, 2025
@Copilot Copilot AI requested a review from premun October 20, 2025 13:07
Copilot finished work on behalf of premun October 20, 2025 13:07
…xcludedAssets as method argument

Co-authored-by: premun <[email protected]>
@Copilot Copilot AI requested a review from premun October 20, 2025 13:37
Copilot finished work on behalf of premun October 20, 2025 13:37
@premun premun marked this pull request as ready for review October 20, 2025 13:50
@Copilot Copilot AI review requested due to automatic review settings October 20, 2025 13:50
Copy link
Contributor

@Copilot 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 adds support for the --subscription argument to VMR codeflow operations (darc vmr forwardflow and darc vmr backflow), enabling users to simulate subscription behavior during manual codeflow operations. This enhances debugging capabilities and provides consistency with existing darc update-dependencies --subscription functionality.

Key changes include:

  • Added --subscription command-line option to codeflow operations
  • Implemented subscription metadata fetching with automatic build selection and excluded assets extraction
  • Replaced hardcoded empty excluded assets arrays with subscription-derived values

Reviewed Changes

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

File Description
CodeFlowCommandLineOptions.cs Added SubscriptionId property and command-line option definition
CodeFlowOperation.cs Implemented subscription metadata fetching, validation, and option population logic
ForwardFlowOperation.cs Updated to accept and use excluded assets parameter from subscription
BackflowOperation.cs Updated to accept and use excluded assets parameter from subscription

/// Fetch subscription metadata and populate command options based on subscription settings.
/// This allows the subscription to be simulated using the existing codeflow logic.
/// </summary>
private async Task<IReadOnlyList<string>> PopulateOptionsFromSubscriptionAsync()
Copy link
Member

Choose a reason for hiding this comment

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

I don't like that nothing about this method name tells you it's gonna return a list of excluded assets. Think it'd be better if it was a parameter, we passed a list, and this method would fill it

Copy link
Member

Choose a reason for hiding this comment

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

I agree. But I think you can't have out parameter in an async method

Copy link
Member

Choose a reason for hiding this comment

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

@copilot can you add a new optional argument to the code flow commands --excluded-assets which would work similarly to the others (like build) that it would be taken from a subscription first and overriden by the argument, if the argument is set.

We then could store it in the _options and would not need to pass it around.

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. Added --excluded-assets option that works like --build - it's taken from the subscription first and can be overridden by the command-line argument. Now stored in _options.ExcludedAssets and parsed when needed, eliminating the need to pass it around as a method parameter.

@Copilot Copilot AI changed the title Support --subscription argument in darc vmr codeflow operations Support --subscription and --excluded-assets arguments in darc vmr codeflow operations Oct 22, 2025
Copilot finished work on behalf of premun October 22, 2025 12:03
@premun premun requested a review from dkurepa October 22, 2025 12:04
@premun premun enabled auto-merge (squash) October 22, 2025 12:14
@premun premun disabled auto-merge October 22, 2025 12:40
@premun premun merged commit 46d585e into main Oct 22, 2025
8 of 9 checks passed
@premun premun deleted the copilot/support-subscription-argument branch October 22, 2025 12:40
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.

Support --subscription argument in darc vmr codeflow operations Handle the new rebase life cycle during codeflow PRs

3 participants