Updated on 2024-07-05 GMT+08:00

Managing MRs

CodeArts Repo supports development of multiple branches and establishes configurable review rules for branch merging. When a developer initiates an MR, some repository members can be selected to participate in code review to ensure the correctness of the merged code.

When a merge request is created, reviewers, approvers, and mergers will be notified by emails and .

Based on the security of the code repository, you are advised to understand and configure the following functions before using merge requests:

Merge Request List

On the Merge Requests tab page, you can view merge requests list page.

  • You can switch between tabs to view MRs in different states.
  • You can click a request to go to the details page.
  • You can view the brief information about the request, including the involved branch, creation time, and creator.
  • You can search for a request based on different conditions.
  • You can click New in the upper left corner to create a request.

Open: The request has entered the review or merge phase, and branches have not been merged.

Merged: indicates that the request is approved and the branch is merged.

Closed: indicates that the request is canceled and the branch is not merged.

All: displays MRs in all states.

Creating a Merge Request

Assume that the administrator has set branch merge rules. To create an MR for a develop branch, perform the following steps:

  1. Go to the details page of a target repository.
  2. Switch to the Merge Requests tab page.
  3. Click New and select the branch to be merged.

    In the preceding figure, Dev (where the development task is completed) is merged into the master branch.

    The branch of a forked repository can be selected as the source branch.

  4. Click Next. The system checks whether the two branches are different.

    • If there is no difference between the two, the system displays a message and the MR cannot be created.
    • If the branches are different, the following Create Merge Request page is displayed.

    The lower part of the Create Merge Request page displays the file differences of the two branches and the commit records of the source branch.

  5. Set the parameters according to the following table.

    Table 1 Parameter description

    Parameter

    Description

    Change Branch

    Click to return to the previous step and change the branch to be merged.

    Title

    Enter the MR title.

    Description

    A default description is generated based on the merge and commit messages of the source branch. You can modify the description as required.

    NOTE:

    The text box uses the markdown format. Max. 5,000 characters. Using the tools on the top bar will replace the characters you enter if they are close to 5,000.

    Associated Work Items

    You can choose to associate a merge action with a work item to automatically change the status of the work item.

    Mergers

    Mergers have permissions to merge branches (by clicking the merge button) when all approvers approve MRs and all discussed issues are solved (or you can set the rule to allow merge with issues unsolved). They can also close the MR.

    Reviewers

    Specified to participate in the merge branch review and can raise questions to the initiator.

    Approvers

    Appointed to participate in the merge branch review. You can provide review comments (approved or rejected) or raise questions to the initiator.

    Delete source branch after merge

    You can choose whether to delete the source branch after merge. The preset status in the MR settings is initially used.

    Squash

    Enabling Squash merge keeps the history of the basic branch clean, with meaningful commit messages, and can be easily restored if necessary. For details, see Squash.

  6. Click Create Merge Request to submit the MR. The details page is displayed.

    On the details page, merge rule statuses, mergers, reviewers, approvers, and associated work items are displayed. You can view review comments, mark a review comment as Unsolved, and view all activities related to the merge request.

    • Commits: You can view commit records of the source branch.
    • Files Changed: You can view the changed content in an MR and filter the change types such as addition, modification, deletion, and renaming.
    • Pipeline: You can view the information about the pipeline.

  • When an MR is created, related members (reviewers and mergers) will be notified by emails. The reviewer cannot be the creator of the merge request.
  • If a single file contains 5000 different lines and there are over 100 different files, you are advised to merge the branch using the client and then push it to CodeArts Repo.

Reviewing, Approving, and Merging MRs

If you are notified of an MR as a reviewer, approver, or merger, perform the following steps:

  1. Go to the details page of a target repository.
  2. Switch to the Merge Requests tab and click the name of the target merge request to view details.
  3. Review the target merge request.

    Both the reviewer and approver can review the merge request and provide review comments. If there is no comment, the reviewer can click Review Pass to complete the review.

  4. Approve the target merge request.

    The reviewer can click Reject or Approve.

  5. Pass the gate.

    Table 2 Merge conditions

    Merge Condition

    Description

    Code merge conflicts

    When the source branch code conflicts with the target branch code, you need to resolve the conflict before proceeding to the next step. For details about how to resolve the code conflict, see Resolving Code Conflicts in an MR.

    Review comment gate

    After the initiator resolves the reviews of all reviewers or approvers, the gate is passed. For details see Detailed Description of Review Comments Gate.

    Pipeline gates

    When the latest commit or pre-merged commit starts and successfully executes the pipeline, the gate is passed. For details see Detailed Description of Pipeline Gate.

    E2E ticket number not associated

    After the combination request is associated with a work item, the gate is passed. For details see Detailed Description of E2E Ticket Number Association Gate.

    Review gate

    When the number of reviewers reaches the minimum number, the gate is passed. For details see Detailed Description of Review Gate.

    Approval gate

    When the number of approvers reaches the minimum number, the gate is passed. For details see Detailed Description of Approval Gate.

  6. Merge the request.

    After an initiator meets the preceding conditions, click Merger to merge the request. Otherwise, click Close to close the request.

Squash

Squash is to merge all change commit information of an MR into one and keep a clean history. When you focus only on the current commit progress rather than the commit information, you can use squash.

If Squash is selected, multiple consecutive change records of the source branch can be merged into one commit record (information of Configure Squash), and this new commit record can be committed to the target branch.

  • If the change history of the merge request contains only one commit, the commit record in the target branch is for the source branch after Squash is selected.
  • If the change history of the merge request contains multiple commits, the commit record in the target branch contains the information of Configure Squash after Squash is selected.

To better understand this function, perform the following operations:

  1. Create a repository.

    Name it repo.

  2. Create a branch.

    Name it Dev.

  3. Submit the creation.

    Take creating a file as a commit.

    Dev branch: Create two files and name them Function_1 and Function_2.

  4. Check the effect before Squash is enabled.

    Find the Dev branch. Click the Code, Commits, and Commits tabs to view the commit information.

  5. Create and merge a request.

    1. Set the source branch to Dev and target branch to master. Create a merge request.

      Dev branch: Name the merge request as Code Merge, select Squash, and enter Configure Squash.

    2. Complete the review and approval.

  6. Check the effect after Squash is enabled.

    After the request is successfully merged, click the Code, Commits, and Commits tabs, select the master branch. Compared with Step 4, the committed content has been merged.