Auto-merge not performed when called by merge-train add merge request API

What does this MR do and why?

This MR introduces a guard clause fixing a bug that caused the merge train to get stuck on the wrong auto-merge strategy when the AddToMergeTrain endpoint would get called again while the MR is already on the train.

This would make the code go through a flow where it doesn't expect the merge request to already be on the train, and the operation returns/stops on a validation step.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Set a merge request to add to merge train when checks pass
  2. When on the train call the REST endpoint with "when_pipeline_succeeds": True. Example call: #508257 (closed)
  3. You should now receive a bad request.

Related to #508257 (closed)

Edited by Panos Kanellidis

Merge request reports

Loading