开始之前
- 安装Git和git-review 。
- Create a new SSH key to use with Wikimedia Gerrit:
- Run the following from your terminal, substituting your email address:
ssh-keygen -t ed25519 -C "your_email@example.com"
- At the "
Enter a file in which to save the key
" prompt, you can press Enter to accept the default if this is your first SSH key. Otherwise, customize it to something like/Users/YOUR_NAME/.ssh/id_wikimedia_gerrit
- At the "
Enter passphrase:
" prompt, choose a strong passphrase. You will typically have to the first time on a given day when pulling or sending change requests.
- Run the following from your terminal, substituting your email address:
- 创建一个维基媒体开发者账户。 Then, log in on gerrit.wikimedia.org and add your public key to your account. The public key is the content of
/Users/you/.ssh/id_wikimedia_gerrit.pub
- Configure Git to set your email address, name, and SSH username.
获取源代码
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 production branch:
mediawiki$ git checkout master mediawiki$ git pull mediawiki$ git checkout -b 一个有意义的分支名
- NOTE: In some cases, the production branch may be called "production" or "main" and require a modified checkout command such as:
mediawiki$ git checkout production
mediawiki$ git checkout main
Now you can edit the code to make and test your changes. 当您满意并确认代码正常工作后:
git commit --all
使用Gerrit时,在每个分支仅执行一次此操作。 To fix mistakes, usegit commit --amend
.git show
检查您的补丁确认您正在提交的内容无误。 按“q”退出。git review
这会将补丁推送至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 在线)上询问。
上传补丁
如果审查者让您做出更改,使用以下命令修改您的提交:
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
这将以反映您更改的新补丁集版本更新Gerrit中的更改请求,并自动通知订阅的审阅者。
参见
- 请尝试遵守我们的提交信息指引。
- See also Getting reviews