Update merge params when auto-merge is set again with the same strategy

What does this merge request do and why?

When auto-merge is already enabled on a merge request, setting it again with the same strategy through AutoMergeService#execute (the REST merge endpoint, the /merge quick action, and other callers) ran the strategy's execute again. Each repeated call ran the strategy's availability checks, fired the update webhooks and enqueued another AutoMergeProcessWorker, even though nothing changed apart from the merge params.

The web controller already avoids this: it calls AutoMergeService#update when auto-merge is enabled. This merge request makes AutoMergeService#execute do the same when all of these are true:

  • auto-merge is enabled with the requested strategy
  • the merge request has a merge user
  • the current user can merge the merge request

Otherwise it runs the strategy's execute as before. The REST endpoint still selects a strategy first, so a repeated auto_merge=true call after the checks pass still merges immediately.

The actual merge still goes through AutoMergeProcessWorker and the strategy's process, which runs the full mergeability checks before it merges. As on the web, a repeated set by a different user does not change the merge_user.

The change is behind the auto_merge_update_on_repeated_set feature flag (gitlab_com_derisk, off by default).

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Enable the feature flag:
    Feature.enable(:auto_merge_update_on_repeated_set)
  2. Create a merge request with a running pipeline.
  3. Call PUT /projects/:id/merge_requests/:iid/merge?auto_merge=true twice.
  4. Check that the second call updates the merge params but does not fire update webhooks or enqueue AutoMergeProcessWorker.

Merge request acceptance checklist

Evaluate this merge request against the merge request acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Phil Hughes

Merge request reports

Loading
Loading