Fix race-condition for merge request MWPS
What does this MR do and why?
After a commit has been pushed, all the merge requests related to that commit (its branch) are asynchronously refreshed.
One of the operations that are performed on those merge requests is aborting MWPS. The following race condition is possible:
- A user pushes a commit
- Sets MR to MWPS (either manually or via push options (more likely))
- Refresh job executes and aborts the just set MWPS
The issue is consistently reproducible via push options usage: Merge requests created with git push options wo... (#368914 - closed)
Solution
When an MR is set for a merge, the merge sha is assigned. We can check whether the merge sha is up-to-date and if it equals to the newrev of the commit that was just pushed, that means that someone already reviewed the changes and set those changes for merging.
The functionality is release behind a feature flag: fix_interrupted_mwps