主题
LibreOffice 贡献代码 -- Gerrit
原文: https://wiki.documentfoundation.org/Development/gerrit
作者: LibreOffice 译者:aqcoder(flw_dream@126.com)
本页介绍如何在 LibreOffice 中使用代码审核工具 gerrit.libreoffice.org。
Gerrit 设置
开始前帮助提示
下面的介绍都很简单,如果你有遇到困难可以通过以下方式获取帮助信息:
- IRC Freenode #libreoffice-dev
- 邮件列表
Gerrit 注册
在 LibreOffice Gerrit 首页 https://gerrit.libreoffice.org/ 的右上角点击注册。选择你的 OpenID 提供的 OpenID 列表。或者使用 [OAuth2 登录。目前支持的 OAuth2 登录方式:
- GitHub
多账号登录
不同的 OpenID 或 OAuth2 账号可以连接到同一个 Gerrit 账号。
警告:不要每次使用新的账号登录 Gerrit,因为这样每次都会创建一个新的 Gerrit 账户。应该使用虚拟的 OpenID 或 OAuth2 账号连接到已经存在的账户:
- 使用已有 Gerrit 账户登录。
- navigate to User => Settings => Identites 或直接转至 https://gerrit.libreoffice.org/#/settings/web-identities
- 点击 "Link another identity" 按钮。
- 选择可选的 identify。、
- 登录。
- 完成。
Gerrit 简单设置
如果你已经 checkout 了一个 libreoffice/core, 你只需要运行脚本 ./logerrit setupd 来自动的设置 keys 和 ssh 等配,它将引导你做以下步骤:
登录 https://gerrit.libreoffice.org 注册并记住用户名。脚本将生成一个 SSH-key,将他保存到 /home/[username]/.ssh/id_rsa.pub。这个 key 以 ‘ssh-ras’ 开始。你必须在注册的时候键入这个 key (或者注册后设置 SSH Public Keys)。
如果 ./logerrit test 失败了并且 ssh -vvv logerrit 信息显示 /.ssh/config 没有权限,在 ~/.ssh 下运行 chmod 600 cofing。
您也可以手动设置,详见 Gerrit 文档 Development/gerrit/setup。
给 Gerrit 发送补丁代码
把您加入到贡献列表
如果您是首次向 LibreOffice 项目贡献代码,请将您加入到贡献者列表中 the developer and contributor list 并声明贡献者的 License。
提交补丁代码进入代码审核
push 您的代码到 gerrit,详见官方文档。
shell
git checkout -b <a_local_branch_name_of_your_choice>
# Do your code changes, make sure it will build
git add file [file ...] # all the new files _and_ changed files
git commit
./logerrit submit master备注:git add + git commit 的步骤可以使用 ‘git gui’ 完成。记住:commit message 尽量不要超过 65 个字符,无论如何都不能超过 70 个字符。
最后一行命令将会把你本地分支的修改推送到远程 master 分支的 review queue(根据您的需要选择需要推到到的分支).作为一个临时贡献者,您提交的 email 地址必须和您的账号的 email 地址相同,否则键不能完成 push。
如果 push 成功了,git 将会报告你的提交正在等待审核。url 将会像这样:https://gerrit.libreoffice.org/#/c/229/。
在代码审核过程你您最好保存在当前分支,这样你随时何以提交最新的修改。
shell
git checkout master当然您也可以切换到主分支进行其他的代码修改。
更多
您还可以使用 ’git review‘ 详见:Development/GitReview。
在 Development/gerrit/SubmitPatch 您可以找到跟多关于这个话题的讨论:
- submitting a new version
- submitting patches as drafts
- submitting pathces to dictionaries, helpcontent2, translations submodules
- ...
更多关于 Gerrit
- 参考 Development/gerrit/PatchReview 如何在 Gerrit 上进行代码审核
- Split Patch after it was uploaded to gerrit
- 查阅 gerrit FAQ,在开发者邮件列表上寻求帮助,查看 Gerrit 官方文档 the official gerrit documentation