The site that you are currently viewing is a static version of the Software Factory documentation delivered with the

version v7.2.
For up-to-date documentation, see the latest version.

GitLab Merge Request

How to use GitLab Merge Request

Approval rules

Create a list of users who act as code owners for specific files and require their approval before merging work.

  • In the root of your repository, create (if not exist) a new directory .gitlab/
  • Create a file CODEOWNERS
  • set the rules based on this exemple :
## Code Owners for a file
filename-path @username1 @username2

## Code Owners for a directory
directory-path/ @username1 @username2

## All group members as Code Owners for a file
filename @groupname

Merge Checks

To configure checks behavior :

  • On the left sidebar, select Search or go tofind your project.
  • Select Settings > Merge Request
  • move to Merge checks part on the page,
  • Check the controles you would like to activate in the checkboxes
  • Add external status check, select Add status check,
    • like SonarQube or Coverity

MR checks

you can also define a template listing actions and format the MR should have:

  • On the left sidebar, select Search or go tofind your project.
  • Select Code > Repository,
  • Next to the default branch, select +, select New file.
  • Next to the default branch, in the File name text box, enter .gitlab/merge_request_templates/mytemplate.md,
    • Choose any name you like instead of mytemplate
  • Commit to your default branch.

On GitLab, navigate to your project. Create a new merge request from your feature branch to your target branch (usually main or master). View Merge Request Details:

Open the newly created merge request. You will see a merge request widget which shows details, discussions, and any merge checks that have been set up. Satisfy Required Checks:

Fulfill the required merge checks. For instance, you might need to: Ensure that the CI/CD pipeline passes. Get the necessary approvals from colleagues. Resolve any merge conflicts if they exist. Follow commit message conventions. Monitor Merge Status:

The status and progress towards satisfying these checks can be monitored directly within the merge request. Typically, you will see a checklist or a series of statuses indicating which checks have been met and which are still pending. Merge the Request:

Once all required merge checks are satisfied, the “Merge” button becomes available. You can proceed to merge the request into your target branch