[ English | Indonesia | 한국어 (대한민국) | español (México) | English (United Kingdom) | Deutsch | 中文 (简体, 中国) ]

设置您的Gerrit帐户

备注

本节假设您已完成 设置和学习Git 指南.

什么是 Gerrit?

这是OpenStack社区使用的审核系统。

Gerrit 可以让你审核:

注册

  1. 访问 OpenStack的 Gerrit 页面 并点击 sign in 链接.

  2. 系统将提示您选择用户名。 您可以输入与Launchpad相同的内容,或其他内容。

备注

请仔细选择并输入您的用户名。 设置后,您无法更改用户名。

备注

从此处开始登录Gerrit时,系统会提示您输入Launchpad登录信息。 这是因为Gerrit将其用作OpenID单点登录。

Individual Contributor License Agreement (ICLA)

What is it?

An agreement to clarify intellectual property rights granted with contributions from a person or entity. Preview the full agreement.

签名

个人贡献者

  1. In Gerrit’s settings click the New Contributor Agreement link and sign the agreement. You need this to contribute code & documentation. You will not be able to push patches to Gerrit without this.

../_images/3.png

来自公司或组织的贡献者

If you are contributing on behalf of a company or organization, please make sure that you sign the ICLA AND also get added to the list of contributors on your company’s Corporate Contributor License Agreement (CCLA). You will need to complete both of these steps before being able to contribute.

  1. In Gerrit’s settings click the New Contributor Agreement link and sign the agreement.

    ../_images/3.png
  2. An employer with the appropriate signing rights of the company or organization needs to sign the Corporate Contributor License Agreement.

  3. If the CCLA only needs to be extended follow this procedure.

备注

Employers can update the list of authorized employees by filling out and signing an Updated Schedule A Form.

来自美国政府的贡献者

Someone of authority needs to sign the U.S. Government Contributor License Agreement. Contact the Open Infrastructure Foundation to initiate this process.

设置SSH密钥

这些是什么?

In order to push things to Gerrit we need to have a way to identify ourselves. We will do this using SSH keys which allows us to have our machine we’re pushing a change from to perform a challenge-response authentication with the Gerrit server.

SSH密钥总是成对生成:

  • 私钥 - 只有你知道,它应该被妥善保护。

  • 公钥 - 可以与您希望连接的任何SSH服务器自由共享。

In summary, you will be generating a SSH key pair, and providing the Gerrit server with your public key. With your system holding the private key, it will have no problem replying to Gerrit during the challenge-response authentication.

Some people choose to use one SSH key pair to access many systems while others prefer to use separate key pairs. Both options are covered in the following sections.

检查现有密钥

打开您的终端程序并输入:

ls -la ~/.ssh

通常,公钥文件名如下所示:

  • id_dsa.pub

  • id_ecdsa.pub

  • id_ed25519.pub

  • id_rsa.pub

如果您没有看到.pub文件或想要为OpenStack Gerrit生成专用配置,则需要生成密钥。

生成SSH密钥对

备注

This guide recommends using ed25519 keys because it has been found that this type works well across all operating systems.

生成默认或初始SSH密钥对

You can generate a new SSH key pair using the provided email as a label by going into your terminal program and typing:

ssh-keygen -t ed25519 -C "your_email@example.com"

When you’re prompted to “Enter a file in which to save the key” press Enter. This accepts the default location:

Enter a file in which to save the key (/Users/you/.ssh/id_ed25519): [Press enter]

At the prompt, type a secure passphrase, you may enter one or press Enter to have no passphrase:

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Generating A Separate Key Pair For OpenStack Gerrit (optional)

You can generate a new SSH key using the provided email as a label by going into your terminal program and typing:

ssh-keygen -t ed25519 -C "your_email@example.com"

When you’re prompted to “Enter a file in which to save the key” you must specify the name of the new key pair and then press Enter:

Enter a file in which to save the key (/Users/you/.ssh/id_ed25519): /Users/you/.ssh/id_openstack_ed25519

At the prompt, type a secure passphrase, you may enter one or press Enter to have no passphrase:

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Finally you need to tell ssh what host(s) to associate SSH keys with. To do this open “~/.ssh/config” in an editor, create the file if it doesn’t exist and add something like:

Host review.opendev.org review
  Hostname review.opendev.org
  Port 29418
  User <your_gerrit_username>
  IdentityFile ~/.ssh/id_openstack_ed25519

Copy Public Key

Mac OS & Linux

From your terminal type:

cat ~/.ssh/id_ed25519.pub

Or if you created a separate key pair, assuming the example name above:

cat ~/.ssh/id_openstack_ed25519.pub

Select and copy the output.

Import Public Key Into Gerrit

  1. Go to Gerrit’s SSH Keys section in User Settings.

  2. Paste the public key into the New SSH Key text box.

  3. Click the ‘ADD NEW SSH KEY’ button.

Git Review

What is it?

Git review is a tool maintained by the OpenStack community. It adds an additional sub-command to ‘git’ like so:

git review

When you have changes in an OpenStack project repository, you can use this sub-command to have the changes posted to Gerrit so that they can be reviewed.

安装

Mac OS

In a terminal type:

pip install git-review

If you don’t have pip installed already, follow the installation documentation for pip.

备注

使用该命令安装时,Mac OS X El Capitan和Mac OS Sierra用户可能会看到类似“不允许操作”的错误消息。 在这种情况下,有两个选择可以成功安装git-review。

选择1:使用额外的选项的pip进行安装:

pip install --install-option '--install-data=/usr/local' git-review

选择2:使用包管理器 Homebrew ,然后终端中键入:

brew install git-review

Linux

对于像Debian、Ubuntu或Mint这样的发行版,打开终端并输入:

sudo apt install git-review

For distributions like RedHat, Fedora or CentOS open a terminal and type:

sudo dnf install git-review

对于SUSE发行版,打开终端并输入:

sudo zypper in python-git-review

配置

Git审核假定您运行它的用户与您的Gerrit用户名相同。 如果不是,你可以通过设置这个git配置设置来告诉它:

git config --global gitreview.username <username>

如果您不知道Gerrit用户名是什么,可以查看 Gerrit设置

准备发送review

在你的补丁进行 git commit 之前,初始化git review很重要。 使用以下命令在仓库中执行初始git review配置:

git review -s

该命令设置必要的远程主机及提交hook以启用对Gerrit的更改。

备注

Git review only needs to be initialized once in a repository.