Configuring Project-Level Merge Request Rules
MR Rules Overview
The MR configuration refers to the configuration of code merge conditions and modes in MR mode. Project-level MR rules can be inherited to the repositories and repository groups.
Constraints
Project manager or project administrator can set project-level webhooks.
Configuring Merge Request Rules
You can select Inherit from project. The settings in the project are automatically inherited and cannot be changed.
You can also access the target project homepage of the code to be configured and choose Settings > Policy Settings > Merge Requests. You can create a merge request rule by referring to the following steps:
- Select a merge mechanism. There are two MR mechanisms: score and approval. The differences between the two mechanisms are as follows:
- Scoring mechanism: This mode includes only code review and is based on scoring. Code can be merged only when the score meets the gate conditions.
- The approval method consists of code review and merge approval. Code can be merged only after the number of reviewers and approvers reaches gate requirements.
- After selecting a mechanism, set other parameters by referring to the following table. The configuration takes effect for the entire code repo.
Table 1 Parameters for setting the merge condition, settings, and mode Parameter
Description
Merge Conditions
Optional. There are two options:
- Merge after all reviews are resolved. After this parameter is selected, if Must resolve is selected as the review comment, a message Review comment gate: failed is displayed and the Merge button is unavailable. If it is a common review comment, the Resolved button does not exist, the MR is not intercepted by the merge condition.
- Must be associated with CodeArts Req The options are as follows:
- Associate only 1 ticket number. After this option is selected, one MR can be associated with only one ticket number.
- All E2E ticket numbers pass verification After this option is selected, all associated E2E ticket numbers must pass the verification.
- Branches to configure the MR policy: You can add multiple branches to configure the merge request policy. You can manually enter wildcard characters (for example, *-stable or production/*), and press Enter.
MR Settings
Optional. Options:
- Do not merge your own requests After this parameter is selected, the Merge button is unavailable when you view the MRs created by yourself. You need to ask the person who has the permission to merge the MRs.
- Do not approve your own requests
- Do not review your own requests
- A repo administrator or project manager can force merge code
- Allow code review and comment for merged or closed MRs
- Mark the automatically merged MRs as Closed If all commits in MR A are included in MR A, MR B is automatically merged after MR A is merged. By default, the B MR is marked as merged. You can use this parameter to mark the B MR as closed.)
- Cannot re-open a Closed MR This function is enabled by default. You can enable or disable it as required.
- Enable "Delete source branch after merged" when creating MRs
- Forbid squash merge (Forbid to select squash merge when creating a merge request)
- Enable Squash merge for new MRs
Merge Method
Mandatory. The options are as follows:
- Merge commit If this parameter is selected, a merge commit is created for every merge, and merging is allowed as long as there are no conflicts. That is, no matter whether the baseline node is the latest node, the baseline node can be merged if there is no conflict.
- Do not generate Merge nodes during Squash merge: If this parameter is selected, no merge node is generated during the squash merging.
- Use MR merger to generate Merge Commit: If this parameter is selected, the commit information is recorded.
Use MR creator to generate Merge Commit: If this parameter is selected, the commit information is recorded.
- Merge commit with semi-linear history. If this parameter is selected, a merge commit is recorded for each merge operation. However, different from Merge commit, the commitment must be performed based on the latest commit node of the target branch. Otherwise, the system prompts the developer to perform the rebase operation. In this merging mode, if the MR can be correctly constructed, the target branch can be correctly constructed after the merge is complete.
- Fast-forward If this parameter is selected, no merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded. When fast-forward merge is not possible, the user is given the option to rebase.
- After setting the parameters, click Submit to save the configurations.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.