官网
https://gerrit.asterisk.org/Documentation/index.html#_quickstarts
gerrit 的结构
-
传统项目
-
gerrit项目
引入了一个新的概念 Pending Changes 所有修改都先发送到Pending Changes, 供其他人查看和讨论 当足够的Reviewer批准代码更改时, 才可以将更改提交代码库
gerrit 的生命周期
-
Making the change
-
Creating the review
""" 提交更改到Pending Change区域 """ git commit git push origin HEAD:refs/for/master # git push origin HEAD:refs/for/<branch_name>
-
Reviewing the change
界面操作 +2 --> Looks good to me, approved +1 --> Looks good to me, but someone else must approve 0 --> No score -1 --> I would prefer that you didn’t submit this -2 --> Do not submit
-
Reworking the change
reviewer 打负分说明需要更改 Cover Message文本框内可以添加理由 通知会通过邮件发给Developer 修改问题后, 再提交审核
-
Verifying the change
验证可以由自动化工具完成, 也可以手动 UI界面内提供了每个分支的下载 Verified 评分+1则验证通过
-
submitting the change
界面操作 在"代码审查"界面打开更改, 并点击"提交" 此时更改合并到代码库的master分支中
commit-msg Hook
"""
顾名思义, 提交消息挂钩
可以将正在审核的相同更改的不同版本链接在一起
"""
# 本地Git库安装钩子后, 消息如下
Improve foo widget by attaching a bar.
We want a bar, because it improves the foo by providing more
wizbangery to the dowhatimeanery.
Signed-off-by: A. U. Thor <author@example.com>
# 插入新的"Change-ID", 消息如下
Improve foo widget by attaching a bar.
We want a bar, because it improves the foo by providing more
wizbangery to the dowhatimeanery.
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
Signed-off-by: A. U. Thor <author@example.com>
# 获取钩子文件, 使用scp wget curl
scp -p -P 29418 <your username>@<your Gerrit review server>:hooks/commit-msg <local path to your git>/.git/hooks/
# 确保钩子文件可执行
chmod u+s <local path to your git>/.git/hooks/commit-msg
添加用户
# 在服务器执行
htpasswd xx/gerrit/review_sites/etc/passwords username
# 根据提示输入密码
# 在web端根据这个用户名密码登录, 注册为gerrit用户
# 在gerrit, project中设置权限