Gerrit/Privilege policy/zh



权利和义务
在大多数维基媒体Gerrit仓库设置中，如果一名用户给出了“+2”的代码审查结果，Jenkins便会在运行测试后自动合并这一更改. 所以给出代码审查+2的权限只赋予特定Gerrit用户组. 通常，每个代码仓库都有以仓库命名的Gerrit用户组，且在该仓库具有权限. 同时，有些Gerrit组在多个代码仓库都有权限. 尤其是 组在MediaWiki内核和所有扩展与皮肤都有权限，外加其他一些与MediaWiki相关的仓库.

Gerrt组可以继承LDAP组的成员. 绝大多数WMF雇员都属于LDAP的 组，从而自动拥有 组的成员资格.

Gerrit管理员可以向Gerrit组中添加或移除成员.

将更改合并到MediaWiki核心或Wikimedia部署的扩展是一件大事. 一旦更改被合并到中，它将“自动”部署到，这是一个虚拟化的暂存环境. 它也将在下一个MediaWiki核心部署窗口中“自动”拾取（请参见部署），除非在剪切发布分支之前将其还原.

您的合并操作可能导致维基百科或其他站点崩溃. 也可能引入安全漏洞，而让攻击者删除、破坏数据，或访问私人信息. 更常见的情况是，如果代码没有测试、测试实现得很差或交互很差，则可能会导致增加. 在使用+2之前，您应该仔细阅读本文档和所有相关政策.

+2是信任的强烈表达，通过良好的判断和谨慎的行动来保持信任.

在代码审查、设计讨论和bug评论中，那些拥有+2能力的人有特殊的责任从他人的角度来看问题.



合并而不审查
未经审查就合并代码不利于代码质量，也不利于士气. +2权限的意义在于“分离开发和代码审查”. 合并Gerrit中的更改的目的是告诉世界：“是的，我已经确保此更改遵循MediaWiki惯例、良好的工程实践，并且是合理的. ” （参见Jeff Atwood的“代码评论：就这么做”. ） 内联注释可以用来指示在合并代码之前应该解决的代码问题.

未经审阅者批准而合并您自己的代码可能会被吊销特权.

这不一定等同于给自己拥有的Gerrit更改+2. 事例：


 * 如果一个更改从审核者那里收到+2，但Jenkins构建失败，则所有者可能需要给它+2才能重新启动构建作业.
 * 恢复通常可以自我合并，只要它正在恢复的提交是最近的. 您正在恢复到当时可能已审核的版本.
 * 在部署分支和Puppet存储库中，更改由执行部署的人员（通常也是作者）合并. 在这些情况下，代码评审通常通过对更改加1表示.
 * Gerrit中的提交可能有两个作者：所有者和上传修改的审阅者. 通常，所有者和审阅者各自审阅对方的作品.  只要所有更改都经过审查和批准，提交就可以合并.

很少有更改是微不足道的，足以进行自我合并. 在某些情况下，比如琐碎的文档更改或只有一个维护人员的项目，可以容忍自合并.

对于未部署到Wikimedia集群的扩展（和其他项目），代码审查策略由扩展的维护者或作者决定. 一些非维基媒体扩展遵循维基媒体禁止自合并的政策，但没有这方面的要求. 如果您是唯一一个编写扩展的人，并且没有人审查您的更改，或者如果扩展被放弃，则可以自行合并您的更改.

Intra-team review and shared ownership
If you're working as part of a team, review by members of your team are not only permitted, but strongly encouraged. Having peers review your code on an ongoing basis is a great way to keep momentum of development going, and ensure that your reviewers are familiar with what you're doing.

When you're doing intra-team review, be especially sensitive about blind spots, cognitive biases, and the need to get buy-in for large changes outside the group of people you're working in. Most open source projects, including MediaWiki, are full of abandoned efforts to create fancy new abstraction layers, skinning systems, testing frameworks, etc. Consider the impact of your changes on the ecosystem as a whole, and engage in conversations through requests for comment, wikitech-l, IRC and other venues. Shared ownership of code (to a greater or lesser degree) helps to ensure that what you're doing has lasting long term value.

Must read for code reviewers

 * - and subpages
 * - and related pages
 * - keep this in mind when making schema changes (which should be implemented following this process)
 * - and related pages
 * - keep this in mind when making schema changes (which should be implemented following this process)
 * - keep this in mind when making schema changes (which should be implemented following this process)



申请Gerrit权限
然后发一封电子邮件到wikitech-l邮件列表.

无论您是哪种情况，都需要在task中注明：


 * Gerrit用户名
 * 您需要哪个（些）仓库的权限
 * reasoning, including links to patches written and reviewed

Developers commenting on a privilege request should consider whether the applicant has contributed high quality patches, has exercised +1 rights well, and has demonstrated competence. Negative comments should be written with tact, they should not be overly strident.

If there is a consensus of trusted developers on the Phabricator task, any of the Gerrit administrators can resolve the request. The task must remain open for at least a week, to allow interested developers to comment. Additional time should be allowed if the request is open during travel or holiday periods.

If there is no consensus on a request in Phabricator, it may be referred to TechCom for adjudication.

Previously, some extension maintainers were given ownership rights on the relevant project in Gerrit, so that they could add new group members without making a request in Phabricator. This model should not be used for new extensions. Gerrit administrators should not grant repository ownership to ordinary developers. Before an extension is deployed to the Wikimedia cluster for the first time, the rights should be audited, and legacy ownership privileges should be downgraded to +2 access.

Expedited process for trusted organisations
Gerrit administrators may immediately act on requests from the following trusted organisations for the granting and revocation of membership in their managed groups, specifically:

It is not necessary to file a Phabricator task or demonstrate consensus.

This facility is intended to allow these organisations to rapidly on-board staff members, who are assumed to be trusted by virtue of the hiring process. It also allows trusted organisations to grant access to volunteers who are well known and trusted by those organisations.

WMF employees may be added to the  group in LDAP when they are hired. Wikimedia Deutschland employees may be added to the  group in LDAP when they are hired.

TechCom, or the CTO in consultation with TechCom, may direct a Gerrit administrator to add any person to a Gerrit group.

Revocation
Revocation of Gerrit rights is permitted in the following circumstances:


 * In an emergency, such as a compromised account, Gerrit administrators may revoke access immediately, at their discretion. Reversal of emergency revocation may be done at the administrator's discretion if the emergency is judged to have passed. TechCom, or the CTO in consultation with TechCom, may review an emergency revocation and direct its reversal.
 * Revocation of privileges of a WMF employee may be directed by that employee's manager, in consultation with WMF Talent and Culture, as discussed in the Staff Handbook.
 * Revocation of privileges from any person may be directed by TechCom, or by the CTO in consultation with TechCom.

The reasons for revocation may include:


 * Merging bad code
 * Merging your own code without review
 * Failing to socialize high impact changes within the development community
 * Not following the guidelines above
 * Inappropriate behaviour, in particular, violating the Code of Conduct
 * Termination of employment or contract

It is WMF policy to revoke all privileges when staff members depart, even if those privileges were granted prior to the beginning of employment by virtue of volunteer work. Consistent application of this policy helps to protect the privacy of departing staff members: no fault is implied. If departed staff members wish to continue to contribute in a volunteer capacity, they may reapply for access by the usual process.

Requesting revocation
Emergency revocation should be requested by directly contacting a Gerrit administrator, for example using IRC. Revocation for reasons of competence or behaviour should generally be handled in private, following a defined escalation path. For more details, refer to the following table:

Amendments to this policy
Amendments to this policy must be approved by the CTO, in consultation with TechCom.

Definitions

 * CTO : The Chief Technology Officer of the Wikimedia Foundation.
 * TechCom: The Wikimedia Technical Committee. For TechCom to decide or direct something means that a meeting of the committee, by remote audio/video conference or in person, with the attendance of a quorum of at least half of TechCom's members, passes a resolution by simple majority or unanimous consent.