Set Review and Merge Restrictions on a Repository Branch

You must be a project owner to configure a branch so that it allows another branch to merge into it only through a merge request after the merge request reaches the required number of approvals.

The number of approvals ensures that specified reviewers of the merge request have reviewed the changes of the review branch. You can't merge a branch outside VB Studio, such as using a Git client, without meeting the number of approvals requirement of the merge request. You can set other review restrictions on a branch, such as whether the last build of the branch must be successful to merge it.

To set review restrictions on a branch:

  1. In the Project Administration Project Administration page, click the Branch Protection Branch Protectiontile.
  2. Click in the Search repositories field and select the Git repository.
  3. Select the Branch name radio button, click in the search field below it, and select the branch.

    If there aren't any rules associated with the branch, proceed to the next step.

    If there are any rules already associated with the branch, those rules will be displayed. You can select a rule to see its protections, which are displayed in the right-hand panel. If the rule has the Requires Review option already selected and the other options (default reviewers, approvals, exempt users, etc.) are acceptable, you're all set.

  4. In the right-hand panel, select the Requires Review option.

When you select the Requires Review option for branch, you can merge a branch after the branch's approvals requirement is met.

Note:

Users in Oracle Cloud Application environments that have multiple VB Studio instances in different identity stripes have username strings that include the environment name, where that user has been defined. Since a unique user may have been defined for multiple environments, this format ensures that one identity can be distinguished from that user's other unique identities. This should help you select the correct user to add.
These are the review restrictions you can set from the Branch Protection page:
Action How To

Set the minimum number of approvals before a branch can be merged to the selected branch

From the Approvals drop-down list, select the minimum number of reviewers who must approve the review branch of a merge request, where the selected branch is the target branch.

Assign default reviewers to a branch

Default reviewers, who have the power to approve merge requests when a branch requires review, are automatically added to the branch's Reviewers list. If there are two default reviewers, both must approve all merge requests for this branch.

To specify default reviewers of the selected branch, click Default Reviewers and select the member, group, or code owner.

Specify users or groups who can bypass the branch restrictions and merge the review branch of a merge request outside VB Studio or without required approvals

In Merge Request Exempt Users, specify the users or groups.

This is useful if you want to allow some users or groups to merge the review branch irrespective of review conditions being met.

Require code owner approvals When you create an MR, neither default reviewers nor code owners are automatically added.
Under Approval Options, select Requires approval from code owners to include file owners as reviewers when any part of the merge request includes files that have been assigned code owners. When selected, code owners must approve merge requests in addition to the number of approvals selected in the Approvals dropdown list:
  • If a file has two or more owners, only one needs to approve the MR.
  • If one or more files have different code owners, at least one code owner from each owned file must approve the MR.

See Assign Owners to Files in the Project's Git Repository for more information about code owners.

If a change is pushed to a branch after some reviewers have approved the merge request, merge only when they reapprove the merge request Under Approval Options, select the Reapproval needed when branch is updated check box.
Do not count Merge Request submitter's approval Under Approval Options, select Do not count Merge Request submitter's approval to not have it count toward the minimum number of approvals.
Configure the default value for the project's rebase and merge/squash/both operations Under Merge Options, click the Allowed Merge Options selection menu in the Merge Options tab on the Branch Protection Settings page, and configure the default value for the branch's merge/squash/rebase operations. You can choose some combination of the following values:
  • Squash and Merge
  • Rebase and Merge
  • Create a Merge Commit
Allow a review branch to be merged to the selected branch only if the MR includes a linked issue (or multiple issues) Under Merge Options, select the Requires linked issue check box.
Allow a review branch to be merged to the selected branch only if the last build of the linked job in Merge Request is successful Under Merge Options, select the Require successful build check box.
Ensure changes pushed to the target branch match the contents of the review branch Under Merge Options, select the Changes pushed to target branch must match review content check box.
Prevent merging any merge requests with "Needs Attention" comments Under Merge Options, select the Allow merge only if there are no comments with Needs Attention status checkbox.
Delete the review branch after merging the Merge Request into the target branch Under Merge Options, select the Delete the review branch after Merge Request is merged into target branch check box to enable deleting the review branch after the MR has been merged into the target branch.

When enabled, the Delete branch option under Post Merge Actions in the Merge dialog will also be enabled by default. Branch deletion can still be bypassed by selecting No in the confirmation dialog. Select Yes to delete the branch after the merge. See step 5 in Merge Branches.