Add `/merge` slash command
When I'm done reviewing a merge request, I would like to post a comment thanking the MR author, as well as merge the actually MR (or enable Merge When Build Succeeds).
Currently, this requires writing a comment like
@author Awesome work!, scrolling all the way to the top of the page, and clicking the "Accept Merge Request" (or "Merge When Build Succeeds") button.
I would like to be able to write the following, to save myself a scroll and a click—I prefer not to get my hands off my keyboard unless necessary.
@author Awesome work! /merge
This slash command would be smart about deciding not to do anything at all (when the user has no access or there is something preventing a merge, like a failing build), merging immediately (when the build has succeeded or there is no build) or enabling "merge when build succeeds".
It should have the same behavior as clicking the button, which means we should automatically refresh the merge widget after issuing the slash command, and reload the page if the merge was successful. This could be implemented similarly to how the sidebar updates when the (EE-only) Time Tracking feature is used: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/870/diffs#0a91e9ec046ccb97e898c1ad724259905ae43608_0_47 We may also want to automatically scroll the user up to the merge widget.
Things to consider:
- How do we deal with a SHA mismatch situation, where the MR was updated after the page was initially loaded, and we want to prevent the user from accidentally merging code they didn't review? We can't easily send the current sha along with the note, as we do with the Merge button.
- In the future, we can add a
/cancel_automatic_mergecommand to cancel the automatic merge after "Merge When Build Succeeds" is enabled, similarly to the button we have in the UI.