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

设置您的Gerrit帐户

注解

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

什么是 Gerrit?

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

Gerrit 可以让你审核:

注册

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

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

注解

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

注解

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

个人贡献者许可协议

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/32.png

来自公司或组织的贡献者

如果您代表公司或组织做出贡献。

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

    ../_images/32.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.

来自美国政府的贡献者

  1. 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密钥对

生成默认或初始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 rsa -b 4096 -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_rsa): [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 rsa -b 4096 -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_rsa): /Users/you/.ssh/id_openstack_rsa

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_rsa

Copy Public Key

Mac OS & Linux

From your terminal type:

cat ~/.ssh/id_rsa.pub

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

cat ~/.ssh/id_openstack_rsa.pub

Highlight and copy the output.

Import Public Key Into Gerrit

  1. Go to Gerrit’s SSH Public Keys settings.

  2. Click the ‘Add Key’ button.

  3. Paste the public key into the Add SSH Public Key text box and click Add.

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

对于像RedHat、CentOS、Fedora 21或更早版本的发行版,打开终端并输入:

sudo yum install git-review

对于Fedora 22或更高版本打开终端并输入:

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只需要在仓库中初始化一次。