Jump to content

代码开发/gerrit/设置

From The Document Foundation Wiki
This page is a translated version of the page Development/gerrit/setup and the translation is 12% complete.

设置以连接到 gerrit

Before you start: Troubleshooting help

The instructions below should be easy and quick to follow. However, if you get stuck somewhere, here is how you get help:

Register in Gerrit for first time

Gerrit uses The Document Foundation's Single Sign-On service for authentication. Create an account there if you don't have one already (several other sites, such as this wiki, use it too). Then simply visit gerrit and click on the “Sign in” link at the top right of the page. You'll be redirected to our central authentication portal, and then back to gerrit once authenticated.

Setting yourself up for gerrit - the easy way

Insert the following snippet into your ~/.ssh/known_hosts file to allow your SSH client to verify the Gerrit instance:

[gerrit.libreoffice.org]:29418 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRYqhKltihIoORKo+i/mP3y/ie+gA5Nn7ghVf40w5QLzMMrkmcleTQQtiFInFmkL1VSaV0cs2hWLcEvPl8yKMwR3nCVcg25qoeZnq9w+MOTXvhHoDlUk8f1l6ttiiDis+55EPUbrlcs9IWbhBzbqksGCMf4XV5aQmmwcAXuHlzEXazNVb2nXhLE39HUUdD1FRAG+YPnmpQWwOPoDR4b+NdPgPneqNJaLIzcufynUmx20JGRX5jzej9a4boPoBRXFLjXCaCqzujDHRRDvx4IR7M7vH2hKr8zx47xjMay9VBEWB7q/ufcyamXc4+qkSWKAek1SIfd2jA6eyDSW0W7JlZ gerrit-code-review at gerrit.libreoffice.org [gerrit.libreoffice.org]:29418 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGE4VsSt5gCCdzRnI0QD7bqiD6dUM5F+plKvar3L6Y6eBipCGl2rK1cDmQCBTgoRvaKsEleh1rQDaxy2JVeeoN4= gerrit-code-review at gerrit.libreoffice.org [gerrit.libreoffice.org]:29418 ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBC7yV2J1L3A5C5Bg9xvLpZkFbp5B87qvwdgBRoelGMpMj091DWdgRkfhw2poCuWbKoulGzIVlLm9w+/eRiOPHb5i+1qLnu8hMi61hjpDjTNWAZ2SvMptA3r+Cn+zoDCa6w== gerrit-code-review at gerrit.libreoffice.org [gerrit.libreoffice.org]:29418 ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAEhAmKU1EYDyXJFnSh1x2ld9AFM2OXyhJxNhOJWugKsmC2IWBk45QCQzp0lkRbvgANFfQlShc8b56f5ynpI7AWzQwDueZLczwuLac48n6OeeEZiz0OXOilfmQwgPC3t14wa+bshEG/NhjuAO/yQS6oljIB3uquKxCU27UCKbG/ftXGJvw== gerrit-code-review at gerrit.libreoffice.org [gerrit.libreoffice.org]:29418 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINDv6wjS6RZnesdVjCNtGeQGImd4H+Kl6n8+pl1crT+/ gerrit-code-review at gerrit.libreoffice.org

If you have a checkout of libreoffice/core already, you can just run ./logerrit setup inside the source code directory. The logerrit script will try to automatically setup keys and configure ssh for you, and if it can't it will guide you through these steps: if necessary, just follow the steps.

The program will tell you to go to https://gerrit.libreoffice.org and sign in to automatically provision your account from our Single Single-On system. The program will also generate a key pair for SSH and print the public part (that is, the content of /home/[username]/.ssh/id_rsa.pub). This is a long random-looking string beginning with 'ssh-rsa'. You must add it to your settings page for gerrit to work from the command line. Paste it into the field that says New SSH key and click the button that says ADD NEW SSH KEY.

If ./logerrit test fails and ssh -vvv logerrit informs you about ~/.ssh/config having bad permissions, run chmod 600 ~/.ssh/config. If ./logerrit test succeeds, nothing happens and after pressing Ctrl + C you will see the message "Your gerrit setup was successful!".

Detailed and nitty-gritty setup topics

设置以连接到 gerrit - 手动配置

  1. Visit https://gerrit.libreoffice.org and click the “Sign in” link at the top right of the page. Once back from our Single Single-On portal the account should be automatically provisioned using full name, primary email address, and username found from your SSO profile. Please contact the Infrastructure Team if authentication is denied; this might be due to a collision (if your username or email address is used by another account) which needs to be resolved manually.
  2. Take note of the username found in your gerrit profile settings. This username is referred to as YOUR_USERNAME_HERE below.
  3. Generate an SSH keypair for gerrit (of course you can also reuse an existing key) and upload the public part in the settings page. Users are associated by username and SSH key.
  4. Add the following to your ${HOME}/.ssh/config:

 Host logerrit gerrit.libreoffice.org
       IdentityFile /path/to/your/private-key
       User YOUR_USERNAME_HERE
       Port 29418
       HostName gerrit.libreoffice.org

Note that /path/to/your/private-key must include the file name as well. For example: ~/.ssh/id_rsa

  • Setup your git repo so that it pushes to gerrit using the SSH key:
  • git config remote.origin.pushurl ssh://logerrit/core

  • Install the hooks:
  • cd .git/hooks && ln -s ../../.git-hooks/* ./

  • and you are ready to go!
  • Now push !

    Other repositories

    Other repositories than core might not have a ./logerrit file. If you already are setup on gerrit for the core repository, you only need to make sure the other repository pushes to the right repository, with the right target.

    For example, if you cloned the infra/devcentral repository, first add the correct remote to your local copy:

    git config remote.origin.pushurl ssh://logerrit/infra/devcentral

    Then, push to the correct target for code review:

    git push origin HEAD:refs/for/refs/heads/master