Merge request merge_status not updated when merging fails due to conflict
Summary
As we found out in #30141 (comment 497615418), when merging a merge request fails due to conflicts, we show the Merge button again after the timer elapses. It won't show an updated status even if the MR actually has conflicts.
Steps to reproduce
This is hard to replicate as it'll be highly dependent on timing.
- Open a MR.
- On the target branch of the MR, make some changes that will conflict with the changes on the source branch.
- Merge the MR before it checks for mergeability.
To consistently replicate this behavior, after step 2, mark the MR as mergeable even if it's not via MergeRequest#mark_as_mergeable!
. This will allow you to merge it even if there are conflicts.
What is the current bug behavior?
It shows the Merge button even after failing due to conflicts.
What is the expected correct behavior?
It should show the "There are merge conflicts" state instead.
Possible fixes
In MergeService#try_merge
, if it fails to merge, mark the MR as unchecked and check for it's mergeability to refresh the MergeRequest#merge_status
.