Gerrit/教程/简短版本

From mediawiki.org
This page is a translated version of the page Gerrit/Tutorial/tl;dr and the translation is 66% complete.
这个简短指南面向有一定Git使用经验的开发者,关于如何使用Gerrit进行MediaWiki开发。 如遇查看包含详细解释的教程,请参看Gerrit/教程

开始之前

获取源代码

Clone the repository using the command in the repository browser (e.g. https://gerrit.wikimedia.org/g/mediawiki/core). You can find these on the list, or from the extension infobox on mediawiki.org. The most commonly cloned repositories are:

对于MediaWiki核心: git clone https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki

或一个扩展: git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/<扩展名>.git

或一个皮肤: git clone https://gerrit.wikimedia.org/r/mediawiki/skins/<皮肤名>.git

编写补丁

Start your branch from the latest master:

mediawiki$ git checkout master
mediawiki$ git pull
mediawiki$ git checkout -b 一个有意义的分支名

Now you can edit the code to make and test your changes. 当您满意并确认代码正常工作后:

  • git commit --all 使用Gerrit时,在每个分支仅执行一次此操作。 To fix mistakes, use git commit --amend.
  • git show 检查您的补丁确认您正在提交的内容无误。 按“q”退出。
  • git review -R 这会将补丁推送至Gerrit并创建一个变更请求。 如果您安装了过时的“gerrit-tools”程序并遇到报错,请安装“git-review”。

You are encouraged to invite one or two maintainers as reviewers on your change. After creating the change request, the git review will have printed the URL for you change request. You can also find your changes through your Gerrit dashboard. 在变更页面的“Reviewers”下,点击“Add Reviewer”铅笔按钮。 在输入框中填写审查者的名字。 如果您不知道要邀请谁,可以查看您所修改的组件的维护者列表,或在IRC (#mediawiki connect)上询问。

上传补丁

如果审查者让您做出更改,使用以下命令修改您的提交:

  • git review -d 变更ID 例如网址https://gerrit.wikimedia.org/r/1234中的1234。 This downloads and checks out the change request from Gerrit.
  • 编辑源文件做出您的更改。
  • git commit --all --amend 您可以多次执行此命令。 编辑提交信息时,须保持“Change-Id”这一行不变。
  • git review -R 这将以反映您更改的新补丁集版本更新Gerrit中的更改请求,并自动通知订阅的审阅者。

参见