Branch and tag review

更新时间:
复制 MD 格式

This topic describes the use cases for the branch and tag review feature and explains how to use it.

Note

This feature is available exclusively in the Advanced Edition. For more information about editions, see Editions.

Use cases

While code review helps manage code changes and prevent unauthorized modifications, users with write permissions can still create or delete branches and tags. Over time, this can lead to a disorganized repository with numerous obsolete branches, which impacts maintenance and development efficiency. The branch and tag review feature solves this problem by requiring a formal review for all branch and tag changes, even those from authorized users.

Differences from code review

A code review focuses on changes to the code itself, for example, to ensure code quality when developing new features or merging branches. In contrast, a branch and tag review focuses on managing changes to the branches and tags within a repository. This process reviews the following actions:

  • Branch operations:

    • Create a new branch.

    • Delete an existing branch.

    • Reset a branch to a historical commit.

  • Tag operations:

    • Create a new tag.

    • Delete an existing tag.

    • Reset a tag.

Enable branch and tag review

To enable branch and tag review, you must use the latest version of the merge request feature, which is currently being rolled out to all users.

After enabling the new merge request feature, go to the page in your repository. Enable Branch Tag Review Pattern and configure its settings.

The following list describes the settings.

  • Review Scope: Specify which branches and tags require a review. You can configure the scopes for branches and tags independently. For example, if you select "All" for branches, a review is created for every branch change in the repository. You can also select "Specified" and use a glob wildcard to require reviews only for specific branches. The basic rules for a glob wildcard are:

    • ? matches any single character except /.

    • * matches zero or more characters within a single path segment.

    • ** matches multiple path segments.

    • For detailed rules, see the glob documentation.

  • Reviewers Allowed to Approve: Select which user roles can approve a branch and tag review.

  • Minimum Number of Approvers Required: Set the minimum number of approvals required to execute a review.

  • Default Reviewer: Select default reviewers who will be automatically added to each branch and tag review.

  • Execute After Review Approval: Select which user roles can execute an approved branch and tag review.

Create a branch and tag review

From the CLI

After you enable branch and tag review, any git push to a branch or tag that matches a configured rule automatically creates a review. Standard code updates are not affected. For example, consider a repository that contains a branch named dev and a tag named v1. The following command attempts to create two new branches (feat and new-feat), delete the v1 tag, delete the dev branch, and update the master branch:

$ git push origin feat:feat new-feat:new-feat :refs/tags/v1 head:master :dev

As shown in the output below, the master branch is updated successfully, and a single branch and tag review is created for the other operations:

$ git push origin feat:feat new-feat:new-feat :refs/tags/v1 head:master :dev
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 321 bytes | 321.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: +---------------------------------------------------------------------------+
remote: | The following tips are provided by Codeup:                                |
remote: +---------------------------------------------------------------------------+
remote: | A ref review has been created, please visit:                              |
remote: | https://codeup.aliyun.com/<org-id>/demo/change/1                          |
remote: +---------------------------------------------------------------------------+
To https://codeup.aliyun.com/<org-id>/demo.git
 - [deleted]               refs/changes/1/head
   0e18264b7d..a60d5d32ab  head -> master
 - [deleted]               refs/changes/1/head
 * [new reference]         feat -> refs/changes/1/head
 * [new reference]         new-feat -> refs/changes/1/head

The created branch and tag review enters a pending state. The top of the review page displays three status indicators: Cannot execute, No Execution Conflicts, and Insufficient approvers. A reviewer must click Approve to enable the Execute button.

From the UI

In the Codeup UI, if you attempt an operation on a branch or tag that matches a configured rule, you cannot perform it directly. Instead, the system prompts you to create a branch and tag review.

Click the Create Review Request button in the pop-up window to start the review process.

Similarly, if you try to delete a protected branch, the system prevents direct deletion and prompts you to create a review.

The Confirm Deletion dialog box appears, and you can click the Create Review Request button to initiate the review.

Operations on tags from the UI follow a similar process.

Execute a branch and tag review

Similar to the new merge request, a branch and tag review uses a description to document the changes but does not include code diffs. To execute a branch and tag review, two conditions must be met:

  1. No Execution Conflicts: An execution conflict occurs when the requested change conflicts with the current state of the branch or tag in the repository. For example, if two separate reviews both request to create a branch named feat, and one is executed first, the other review enters a conflicted state and cannot be executed.

  2. Sufficient Number of Approvals: The review must have the minimum number of approvals defined on the page.

    If the number of approvals is below the minimum requirement, the status bar on the review page displays Insufficient approvers and Cannot execute, and the Execute button is disabled.

  3. Once the review is approved and has no conflicts, click Execute to apply the changes, such as creating the feat branch.