Author: Hu Rui, Unit: China Mobile Smart Home Operation Center Labs GuideAndroid source code is an open source operating system based on Linux. Currently, the code management tool for Android ROM development basically uses Git. Since Android code is very complex, Google divides it into multiple git repos, which not only avoids too much code in one repo, but also allows it to be assigned to different teams for management and control according to the function of the repo. In order to control the quality of Android code, Google uses Gerrit for coderview, and uses Jenkins for static code detection and automated verification, and of course integrated CI tools. At present, the AOS-RM project of China Mobile Smart Home Operation Center has deployed its own Gerrit server, and Gerrit has played a very important role in the code quality management of the AOS-RM project. As an Android ROM developer, it is necessary to understand what Gerrit is, what the Gerrit workflow is like, how to build a Gerrit server, and how to import the Android codebase into your own Gerrit server. This article will answer the above questions in detail. Part 01 Introduction to GerritGerrit is a free and open source code review system tailored by Google for Android system development, using a web interface. Using a web browser, software developers in the same team can review each other's modified code and decide whether to submit, rollback or continue to modify. It uses the version control system Git as the underlying layer. Currently, Gerrit is widely used in Android development, especially companies doing Android ROM development basically use Gerrit for code review. According to statistics, the top 3 fields using Gerrit are IOT, Software Development and Big Data. Data source: https://www.slintel.com/tech/source-code-management/gerrit-market-share Part 02 Gerrit workflow
Part 03 Gerrit server setup3.1 Install gitsudo apt-get install git 3.2 Install JDK11sudo apt install openjdk-11-jdk 3.3 Install gitwebsudo apt-get install gitweb 3.4 Download the Gerrit installation packagewget https://gerrit-releases.storage.googleapis.com/gerrit-3.5.1.wa 3.5 Install Gerrit (gerrit-3.5.0.1.war is stored in the ~/gerrit directory)cd ~/gerrit The password for sending emails is saved in secure.config. The password for sending emails is the authorization code. 3.6 Install Apachesudo apt-get install apache2 3.7 Configure Apachesudo vim /etc/apache2/httpd.conf The content is as follows 3.8 Enabling the proxy modulesudo a2enmod proxy 3.9 Add Accounthtpasswd -b /xxx/passwords account xxxx 3.10 Start Apachesudo systemctl start apache2 3.11 Start gerrit/xxxx/bin/gerrit.sh start 3.12 Accessing Gerrithttp://IP address:port number/ Part 04 Importing Android Codebase into Gerrit4.1 Create AOSP repositoryUse your browser to create an AOSP repository on the Gerrit server and set Only server as parent for other repositories to True 4.2 Download Android Codebase (change the -u parameter according to the actual situation)repo init -u https://android.googlesource.com/platform/manifest --mirror 4.3 Create a repo (change the IP to your own server IP address)4.3.1 Loop to create reporepo forall -c 'echo $REPO_PROJECT; ssh -p 29418 account@IP gerrit create-project --owner AOSP_account $REPO_PROJECT; 4.3.2 Setting the parent of the reporepo forall -c 'echo $REPO_PROJECT; ssh -p 29418 account@IP gerrit set-project-parent --parent AOSP $REPO_PROJECT; 4.3.3 Push the codebase code to the Gerrit serverrepo forall -c 'echo $REPO_PROJECT; git push Part 05 Generate and customize manifest5.1clone a copy of the platform/manifest repository codegit clone "ssh://account@IP:29418/platform/manifest" && scp -p -P 29418 account@IP:hooks/commit-msg "manifest/.git/hooks/ 5.2 Copy the manifest in the repository and rename itBe sure to set the review field, otherwise the code after repo sync will not generate a change id If you want to add your own unique repository, add a project node and configure the name, path and revision. Finally, submit the new XML file to the gerrit server and merge it to the remote repository after the review is completed. Part 06 Downloading and uploading coderepo init -u ssh://account@IP:29418/platform/manifest.git -b branch_name --repo-url=ssh://account@IP:29418/repo.git -m mymanifest.xml Part 07 Warehouse Permission ConfigurationFor detailed instructions, please refer to: https://gerrit-documentation.storage.googleapis.com/Documentation/3.5.0/access-control.htm In the configuration, you need to modify it according to the actual situation. Different groups have different access rights to different repositories. Remember not to open the push permission to refs/*, otherwise the developer can skip Gerrit and push directly to the git server. |
<<: Why iOS consumes more power when background apps are turned off manually?
>>: CI build performance issues caused by upgrading JDK 11 on Feishu Android
The ozone hole over Antarctica in September this ...
It is an indisputable fact that the entire Chines...
When it comes to product-based new user acquisiti...
Products and operations may indeed conflict over ...
Traffic is actually not difficult, especially gen...
Who is the most popular beverage in the beverage ...
[[150443]] By DS Those who work as planners all t...
This article is based on answering netizens' ...
Produced by: Science Popularization China Author:...
There is a story in the advertising industry that...
Recently, a type of liquid oxygen-kerosene engine...
199IT News, April 24th. Recently, Gartner, a glob...
Review expert: Peng Guoqiu, deputy chief physicia...
How many obese people are there in China? After 1...
Xiaohongshu is a sharing community that started o...