Using merge requests

更新时间:
复制 MD 格式

Codeup allows you to create merge requests to initiate code reviews. After the code passes both manual and automated reviews, you can merge the code into the target branch.

Step 1: Create a merge request

  1. On the Merge Requests page, click New merge request. In the new merge request dialog box, enter the basic information.

    Parameter

    Description

    Source

    The branch containing the changes to be merged.

    Target

    The branch into which the changes will be merged.

    Title

    The title of the merge request.

    Description

    Provide context for the merge request, such as background information and dependencies.

    Reviewers

    Select reviewers for the changes.

    • If default reviewers are set (for details, see Branch settings), they are automatically added.

    • If the CodeOwner mechanism is enabled (see CodeOwner mechanism), matching CodeOwners are automatically added as reviewers. The merge request requires at least one CodeOwner to Approve. If no CodeOwner rule matches a repository member, at least one reviewer must Approve.

    Tag

    Add a tag to categorize the merge request.

    Associated work items

    Link a work item from an Alibaba Cloud DevOps project to provide additional context.

  2. After you enter the information, click OK to create the merge request.

Step 2: Review and approve the request

  • Resolve code conflicts: If a code conflict exists between the branches, the system blocks the merge operation. Codeup provides two ways to resolve conflicts:

    CLI

    # Step 1: Fetch and switch to the source branch
    git fetch origin
    git checkout -b sourceBranch
    # Step 2: Merge the target branch
    git merge origin/main 
    # Step 3: Resolve conflicts and push
    git add <conflicted-file>
    git commit
    git push origin sourceBranch

    Online conflict resolution

    When you open the online conflict resolution tool, the system displays the conflicting files and code sections. The page shows that you are resolving a code conflict from the feature/scan branch into the main branch. The left panel lists the conflicting files, such as file.txt. The main area shows the conflict content for that file, including the <<<<<<< main and >>>>>>> conflict markers. Above the code area, you have three options: Use current change, Use incoming change, and Keep both changes. After resolving all conflicts, click Submit changes in the upper-right corner to complete the merge.

  • Reviewer checkpoint: The system blocks the merge if the number of approvals is less than the required value. For more information, see Configure code review rules.

  • Comments: Unresolved comments are listed in the Unresolved panel. Click a comment to navigate to its location in the corresponding version.

    Click Mark as resolved below a comment to resolve it.

    You can publish an inline comment directly or save it as a draft. Drafts are only visible to you. After you finish your review, you can submit all your draft comments at once.

    On the merge request details page, if a code conflict exists, the page displays Cannot be merged and Code conflict unresolved status labels. On the File changes tab, you can view a diff comparison for each file. Inline comments posted by reviewers on changed lines are displayed to the right of the corresponding code.

  • Automated checkpoints: Automated checkpoints can include code detection tasks and automated pipeline runs. To learn how to set them up, see Automated execution checks.

    Once configured, any update to the merge request triggers these automated checks to aid the code review. You can click a check result to view its details.

    On the Automated Checks tab, a summary at the top shows the number of failed, abnormal, running, and passed checks. The left panel lists each check item, such as Alibaba Cloud DevOps pipeline and Alibaba Cloud DevOps code detection, with its pass or fail status. The main area displays the execution details for the selected pipeline, including the results of tasks like Java code scanning, Maven unit testing, and Build Docker image with Java and push to repository. If a task fails, you can click Retry to run it again. If any check fails, the merge request shows a Checks have not passed status, and the Merge button is disabled.

  • Submit a review decision

    Reviewers with approval permissions can click Finish review to open the feedback panel and select one of the following options:

    • Click Approve to accept the changes.

    • Click Request changes to indicate that modifications are required. The merge is blocked until the author submits new changes and you approve them.

    • Click Comment only to leave feedback without making an approval decision.

    When you submit your decision, you can also publish any draft comments.

    If the merge request status bar shows Comments unresolved, the merge operation is blocked. You must find all comments with an Unresolved status, address the feedback, and then click the Mark as resolved button for each one. The merge can only proceed after all comments are resolved.

Step 3: Merge the branch

After all checkpoints have passed, you can merge the branch. Click the Merge button in the upper-right corner, select a merge strategy, and submit.