Branch collaboration models
This topic guides you through the branch collaboration models of the Apsara DevOps platform. It covers the AGit-Flow Alibaba centralized Git workflow, how to use and configure the git-repo tool, and how to submit code reviews and run automated checks. These tools and practices help you improve team collaboration and code quality.
AGit-Flow Alibaba centralized Git workflow
Overview: Learn about the AGit-Flow Alibaba centralized Git workflow and how it simplifies the code review process.
What is AGit-Flow?
AGit-Flow is a centralized Git workflow. It combines the ease of use of GitHub with the powerful code review features of Gerrit. It allows developers to start a code review with the git push command. You do not need to create a forked repository or a feature branch. This significantly improves the speed and consistency of code reviews.
Single-repository workflow example:
A developer clones the repository. After developing locally and creating commits, the developer uses the
git prcommand to push changes to the server. This automatically creates a pull request for other members to review.Reviewers can download the pull request with the
git downloadcommand to make local changes. They can then use thegit pr --changecommand to update the existing pull request.The project manager completes the merge by clicking the merge button.
Multi-repository collaboration demo:
For more information about complex multi-repository projects, see the official documentation.
Install and configure git-repo
Overview: Explore git-repo, a powerful client tool that simplifies traditional Git commands and lets you start code reviews directly from the client. Follow the guide to install and configure the git-repo tool.
Prerequisites:
Make sure Git is installed before you use git-repo.
Procedure:
Download the git-repo package for your platform and set the correct permissions.
Add git-repo to a system path to make it globally available.
Use the
git repo --versioncommand to verify the installation.Modify the
.git-repo/config.ymlfile in your home directory to customize the log level and other options.
Software upgrade:
Run the
git repo upgradecommand to automatically download the latest version and replace the existing installation.If a permission issue prevents the automatic upgrade, you must manually copy the new file to the target location.
Submit a code review with git-repo
Overview: Use git-repo commands to quickly submit code for review. This improves team communication and collaboration.
Single-repository code review flow:
Create a review: Clone the remote repo. Create a feature branch (optional). After development, use the
git prcommand to initiate a review.Provide review details: Enter a title, description, and reviewers in the editor that opens. Save your changes and exit to push the code.
Update the review: After making changes based on feedback, run the
git prcommand again to update the existing review.Download and update: Reviewers can also download the code, make local changes, and then use the
git pr --changecommand to update the review.
Authorization model:
Creating a review requires only read permission. To update a review, you must be the author or a listed reviewer.
For more information, see Submit a code review with git-repo.
Use a centralized workflow for code reviews and automated checks
You can set branch protection rules and use automated checks to ensure that code changes are reviewed before they are merged into the main branch.
Procedure:
Repository settings: Set protection rules for key branches to prohibit direct pushes and require merge requests to merge code.
Automated check settings: Associate a Flow pipeline and configure gates to ensure that every commit triggers the required automated tests.
Local push to create a review: After a developer finishes their work, they use a git-repo command to push code to a protected branch. A merge request is automatically created for review.
For more information, see Use a centralized workflow for code reviews and automated checks.
This information helps you understand and use the branch collaboration patterns, tools, and technologies available on the Apsara Devops platform.