版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Android source code management,An introduction to Git, Repo, and Gerrit for Android developers.,Toolchain overview,Our Android source code is managed very differently from the OSE phones. Weve fully embraced the Google toolchain, which means a whole new set of tools to work with.,ClearCase,Git,CME,R
2、epo,DeliveryWeb,Gerrit,Version control,Repository mgmt,Delivery,Code review,Android 是谷歌(Google)开发的适合手持设备的操作系统,提供了当前最吸引眼球的开源的手持设备操作平台,大有超越苹果(A)专有的 iOS 系统的趋势。而 Android 的源代码就是使用 Git 进行维护的。Android 项目在使用 Git 进行源代码管理上有两个伟大的创造,一个 是用 Java 开发的名为 Gerrit 的代码审核服务器,另外一个就是本章要重点介绍的repo。,Introducing Repo,Repo is a
3、Google-developed tool for managing multiple Git repositories and submitting code for review to the Gerrit code review system. The Android platform source code consists of hundreds of repositories. Repo keeps track of the available repositories and helps us perform tasks on all of these usually with
4、one single command. Like CME, Repo wraps but does not replace the underlying version control system. In your daily work youll use both Git and Repo. The collection of git repositories is recorded in a manifest file. The manifest file is an XML file with a list of repositories and corresponding branc
5、hes, revisions, or tags. It is quite similar to the Modules section of a 1551 file.,The most common Repo commands,$ repo syncDownloads the latest changes in all repositories, rebasing your own branches as necessary. $ repo startCreate a new branch for working on a topic. $ repo uploadUpload one of m
6、ore changes to the Gerrit code review system.,Introducing Gerrit,Gerrit is a Google-developed tool thats used by their Android open source project (AOSP). It is purely web based and relies on Git for storing the source code. Each Git commit becomes a change when uploaded to Gerrit. A change is subje
7、ct to review and verification by one or more parties. The uploader of a change can at any time update the change. When the change is verified and approved, the uploader will submit the change to the designated branch. After the change has been submitted, it is no longer possible to update it. Gerrit
8、 automatically tracks dependencies between changes in the same git.,Integrated change,The life of a source code change,Git,Hack hack hack,git commit,repo upload,Reviewable,Code reviewed,Verified,Code reviewed repo upload Now Gerrit takes over and you start over on a new branch $ repo start newtopic0
9、58 .,Repo init,repo init u -b Running repo init will download the manifest and repo repositories. Where repo can find the manifest repository is handled with the -u option. If a manifest branch is specified with the -b option, this branch of the manifest git will be checked out. If no branch is spec
10、ified, the master branch of the manifest will be used. Example: repo init -u git:/ b ohd-cupcake-deckard,Repo sync,repo sync . repo sync will iterate through the specified or all repositories listed in the manifest and download the latest changes. After all changes are downloaded, your topic branch
11、will be rebased on top of the latest version of the branch listed in the manifest for that repository. Normally, this version will be the latest approved version on the parent (release/integration) branch. Only non-delivered topic branches will be rebased with repo sync. Never manually resolve any u
12、pload conflicts with git merge!,Repo start,repo start -all | . repo start creates a new branch starting from the revision (of the corresponding project) that is listed in the manifest. When using Gerrit, this means that the branch will always be based on the latest approved software without any depe
13、ndencies to changes that have not passed review.,Repo upload,repo upload . | -replace repo upload will push your changes to Gerrit for review. All commits not already delivered will be uploaded. Each commit will be a new change. If you have amended your commit, you can replace the change set for a G
14、errit change by using the -replace option.,Repo download,repo download project / Downloads and checks out the specified change from Gerrit This commit can be amended and uploaded again using repo upload -replace,Repo abandon,repo abandon If you realize that what you were working on should be scrappe
15、d, you can abandon this topic. repo abandon only affects your local repository. You can also abandon a change in Gerrit. This will only affect that change in Gerrit and not affect any Git repository.,Repo prune,repo prune . When you have uploaded your topics and they have been merged by Gerrit, you
16、can run repo prune. repo prune will delete topic branches that are already merged to the integration branch. Only topic branches that have been merged to the integration branch will be deleted this is a safe command to run.,Repo forall,repo forall . -c . Runs a loop which will execute on every git r
17、epository. This is handy when there is no corresponding repo command for what you want to do.,Gerrit doesnt merge my commit,Your commit was approved and you submitted the change, but Gerrit still says “Review in progress” Check the change comments. If Gerrit had problems merging the commit, it will
18、be listed here. If a merge conflict was the problem, make sure you have the latest changes synced to your workspace. Checkout your topic branch with the change in question on it and rebase it against the parent branch. The you can replace the old commit.,$ repo sync $ git checkout my-old-topic $ git
19、 rebase m/sw-integration $ git mergetool $ git rebase -continue $ repo upload -replace .,I forgot repo startwheres my commit?,If you forget to run repo start to create a topic branch, you will by default work on a “detached head”. I.e. any commits you make after that will float around headless. You
20、can recover. Run git reflog and find the commit you made. Start a new topic branch Then cherry-pick the commit using the first characters from the hash key as listed in the reflog and you are back on track.,$ git reflog d230d0e. HEAD0: commit: Removed Camera/Album app. Its in the Camera apk. $ repo
21、start new-topic . $ git cherry-pick d230d0e,Changeset abuse Scenario One,You made a really cool change and committed it. Unfortunately, that last “harmless” edit you made turned out to break everything If you worked on a topic branch, you have only harmed yourself You edit the file so that it works
22、again and commit the fix. Now you want to share your nice new and working feature with others You upload your topic branch to Gerrit. Repo will upload ALL your commits on the topic branch including the broken one Someone discovers the error in the first commit during review. What happens?,Multiple c
23、ommits in one change,Multiple commits multiple changes to review in Gerrit Which commit should be approved? How does the reviewer know what happened? If the broken commit is rejected, the second, containing the fix, can never be merged as it depends on the rejected one.,Integration branch,Two commit
24、s,Upload,Two changes,Amending commits,If you discover that your previous commit was incomplete or broken you canAmend it! Check out the relevant topic branch Make your fix Add the changes to the index with git add Now create a new commit, where you “fuse” your changes in the index with the previous commit: git commit -amend Presto changeo! You have a new comm
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 翻译公司译员招聘协议
- 房地产公司办公费用控制
- 机电工程人工费施工合同
- 中心站服务改进战略
- 工程公司职工胸牌管理办法
- 网络安全招投标小组职责探讨
- 农场兽医服务合同范本
- 《Excel数据获取与处理实战》 课件 第7章 函数的应用-1
- 2022年大学生物工程专业大学物理下册月考试题A卷-含答案
- 防盗门锁系统
- 数据分析师历年考试真题试题库(含答案)
- 心房颤动与认知功能障碍发生机制研究进展
- 2024年江苏省高考化学试卷(含答案解析)
- 广东省珠海市2023-2024学年六年级上学期数学期中试卷(含答案)
- 2024~2025学年高二地理期中考试模拟试卷【人教版选择性必修一第一至三章】
- 成都银行招聘真题
- 2023年中国铁塔招聘考试真题
- 人教版(2024新版)七年级上册英语Unit 3 单元测试卷(笔试部分)(含答案)
- 江苏省南京市六校联考2024-2025学年高一上学期期中考试英语试卷(含答案含听力原文无音频)
- 2024年海南省发展控股限公司子公司招聘11人高频难、易错点500题模拟试题附带答案详解
- 小学心理健康教育课件《放飞烦恼-拥抱快乐》
评论
0/150
提交评论