"Revert" button disappears when it shouldn't
Summary
When reverting a Merge Request, if the user checks "Start a new merge request with these changes", but then clicks "Cancel" when creating the new Merge Request, the original Merge Request no longer has the "Revert" button.
Steps to reproduce
- Create a Merge Request on a project
- Merge the Merge Request
- Click the Revert button on the Merge Request
- Check the box for "Start a new merge request with these changes"
- On the next screen for creating the new Merge Request, click Cancel
- Go back to the previous Merge Request. The Revert button is no longer there
Expected behavior
I would expect to still see the Revert button since the Merge Request has not been reverted yet.
Actual behavior
The Revert button disappears
Possible fixes
The problem is that the Revert button creates a Revert commit even if the new Merge Request is not created. Therefore MergeRequest#can_be_reverted?
returns false because it detects a Revert commit is already present in the repository.
Two possible solutions I can think of:
- Rather than just checking for a Revert commit, check to see if that Revert commit is either on the master branch, or has a Merge Request assigned to it.
- If a Revert commit has been created, link to that commit on the Merge Request page, so at least the user can view the commit and create a new Merge Request if desired (see #13997 (moved))