Add the ability to set the “merge when pipeline succeeds” flag

Problem to solve

I often need to create many MRs against multiple projects, such as working around GitLab CI's lack of a Dependabot equivalent or when applying comment policy to all of the projects in a repository. This morning, I was working around the Code Quality template not using the dependency proxy by default, which causes it to fail due to Docker Hub rate-limiting.

It's easy to script these updates using glab mr create but that still requires me to open a browser to click the “Merge when pipeline succeeds” button.

Proposal

Add --merge-when-pipeline-succeeds as an option to glab mr create and/or fix glab mr merge --when-pipeline-succeed (see below).

Further details

I considered using glab mr merge --when-pipeline-succeed but there are a number of bugs in that command:

  1. It doesn't correctly pick up the project defaults for the merge method so you have to specify something like --rebase to pass input validation.
  2. It triggers an extra pipeline run unnecessarily, possibly due to not correctly picking up the fact that a pipeline is already running
  3. It doesn't actually work: using it will fail with #1: PUT https://git.example.org/api/v4/projects/group/project/merge_requests/50/merge: 405 {message: 405 Method Not Allowed} and no diagnostic output to explain why that fails when the web UI works.

Links / references

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information