Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 1, 2025

This PR adds a --force option to the darc trigger-subscriptions command to allow forcing updates of existing pull requests even when they have pending or successful checks.

Problem

When triggering a subscription via darc trigger-subscriptions, the corresponding PR only gets updated if it's failing. A successful or pending but not failing PR won't get updated. Instead, Maestro waits until that one is merged and then opens a new one.

This behavior can be problematic when users want to force an update to an existing PR regardless of its current status.

Solution

Added a --force option that bypasses the InProgressCannotUpdate status check in the PR updater logic. When this flag is used, PRs with pending or successful checks can still be updated.

Key Changes

  1. CLI Interface: Added -f, --force option to TriggerSubscriptionsCommandLineOptions
  2. API Layer: Updated all controller versions (2018, 2019, 2020) to accept force query parameter
  3. Work Item Layer: Enhanced SubscriptionTriggerWorkItem with Force property
  4. PR Updater Logic: Modified ProcessPendingUpdatesAsync to bypass status checks when forced
  5. Client Libraries: Updated interfaces and implementations to support the force parameter

Core Implementation

The main fix is in PullRequestUpdater.ProcessPendingUpdatesAsync():

case PullRequestStatus.InProgressCannotUpdate:
    if (forceUpdate)
    {
        _logger.LogInformation("PR {url} cannot be updated normally but forcing update due to --force flag", pr.Url);
        // Continue with the update despite the status
        break;
    }
    await ScheduleUpdateForLater(pr, update, isCodeFlow);
    return;

Usage Examples

# Force update a specific subscription
darc trigger-subscriptions --id 12345-67890 --force

# Force update subscriptions matching criteria  
darc trigger-subscriptions --source-repo dotnet/runtime --target-repo dotnet/installer --force

Testing

  • Added comprehensive unit tests for the new functionality
  • Verified CLI help text shows the new option correctly
  • Confirmed all builds pass with the changes

Fixes #4845.


💡 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.

Copilot AI changed the title [WIP] Add --force option to darc trigger-subscriptions Add --force option to darc trigger-subscriptions command Jun 1, 2025
Copilot AI requested a review from premun June 1, 2025 14:54
Copilot finished work on behalf of premun June 1, 2025 14:54
Copilot finished work on behalf of premun June 2, 2025 08:06
Copy link
Member

@premun premun left a comment

Choose a reason for hiding this comment

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

Add a unit test to PendingUpdatesTests which will test that when passing the new force, a new build is applied even when the exiting PR has pending checks and cannot be updated at that time.
Get inspiration for instance from how the PendingUpdatesUpdatablePr is set up

Copy link
Contributor Author

Copilot AI commented Jun 2, 2025

Add a unit test to PendingUpdatesTests which will test that when passing the new force, a new build is applied even when the exiting PR has pending checks and cannot be updated at that time.
Get ...

Added the requested unit test PendingUpdatesForceUpdateNotUpdatablePr that verifies a new build is applied even when the existing PR has pending checks and cannot be updated normally when using the --force flag. The test follows the same pattern as PendingUpdatesUpdatablePr and confirms the force functionality works correctly. Commit: fa2cd66

Copilot finished work on behalf of premun June 2, 2025 09:45
@premun premun marked this pull request as ready for review June 2, 2025 10:18
Copilot finished work on behalf of dkurepa June 2, 2025 10:33
@dkurepa
Copy link
Member

dkurepa commented Jun 2, 2025

looks like my approval is no good now too because of the comment

Copilot finished work on behalf of premun June 2, 2025 10:34
@premun
Copy link
Member

premun commented Jun 2, 2025

It looks like your approval did not do the trick

@premun premun merged commit ba8bff1 into main Jun 2, 2025
9 of 10 checks passed
@premun premun deleted the copilot/fix-4845 branch June 2, 2025 12:19
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jun 4, 2025
dkurepa added a commit to dkurepa/arcade-services that referenced this pull request Jun 4, 2025
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.

Add --force option to darc trigger-subscriptions

4 participants