Problem

There are times when it’s interesting to disable the possibility to merge a merge request. The merge request might be in a mirrored repository, or you might just prefer manually merging branches.

Solution

The “Merge” button behaviour (enabled/disabled) is driven by the method isMergeButtonDisabled which returns a boolean indicating whether the merge button should be disabled or not.

The cleanest way to modify this behaviour is to tinker with the Vue files that Gitlab comes with. However, since these components are not served directly (they are compiled and bundled using webpack) this means that compilation is needed, which might be a hassle.

The other way is to modify the webpack bundle directly. The instructions below are for a self-hosted Gitlab instance, Debian install, version 15.8. But they probably apply with minimal modifications to Omnibus as well.

Warning: At this point I’m assuming you know what you’re doing, or otherwise you risk crippling your Gitlab installation.

Your mileage may vary but my bundle is stored in /var/lib/gitlab/public/assets/webpack (this is a Debian distrib Gitlab). Go into this directory and do:

grep isMergeButtonDisabled * | cut -f1 -d:

A match should be in a file called pages.projects.merge_requests.show.*.chunk.js. Edit this file (make sure to do a backup first), search for isMergeButtonDisabled. Change the function to read instead of:

isMergeButtonDisabled(){const{commitMessage....

to:

isMergeButtonDisabled(){return true;const{commitMessage....

Don’t forget to remove the pages.projects.merge_requests.show.*.chunk.js.gz as otherwise that one will be served instead of the modified version. Alternatively you can also use gzip in order to replace the existing archive.

Need help with setting up Gitlab? Contact us at www.snowlinesoftware.com for help.