1 # OpenBMC Gerrit Setup/Integration 2 3 **Document Purpose:** Walkthrough configuring your workstation and a Gerrit 4 account. This is needed to participate in OpenBMC's 5 Gerrit-based code reviews. 6 7 **Prerequisites:** Current Linux, Mac, or Windows system. Git packages 8 installed. E-mail account (recommended to use the same e-mail 9 address for both Gerrit and GitHub). 10 11 ## Initial Setup 12 13 ##### Update Git Identity 14 15 * `git config --global --add user.name "Your name" (eg. John Smith)` 16 * `git config --global --add user.email "youremail@your-domain" 17 (eg. jsmith@somedomain.com)` 18 * (Optional) `git config --global --add diff.tool "preferred diff tool" 19 (eg. gvimdiff or meld)` 20 21 22 ##### Setup SSH Keys 23 Create keys: ```ssh-keygen -t ed25519 -C "your_email@your-domain"``` 24 * Recommended to use the defaults instead of picking your own directory/file 25 names. 26 27 Add Keys to GitHub: 28 * <https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/> 29 30 Add Keys to OpenBMC's Gerrit Server: 31 * Login to [Gerrit](https://gerrit.openbmc.org/) with your GitHub 32 account. 33 * Go to 34 <https://gerrit.openbmc.org/plugins/github-plugin/static/account.html> 35 * Your information should be auto-filled, so click "Next". 36 * If successful you should see a blank screen, feel free to exit out. 37 38 ##### Add e-mail to Gerrit 39 * Login to [Gerrit](https://gerrit.openbmc.org/) 40 * Enter e-mail in Settings -> Contact Information -> Register New E-Mail 41 * Check e-mail for confirmation and click the link to confirm 42 43 ##### Add full name to Gerrit 44 * Enter your full name in Settings -> Profile -> Full name 45 46 ##### Add SSH config entry 47 Add the following to `~/.ssh/config`: 48 ``` 49 Host openbmc.gerrit 50 Hostname gerrit.openbmc.org 51 Port 29418 52 User <Your Gerrit Username> 53 ``` 54 * **NOTE**: There is a bug in AFS that requires `AFSTokenPassing no` to be 55 added to the SSH entry if using AFS. 56 * Your Gerrit Username can be found in Gerrit under Settings -> Profile -> Username 57 * Ensure proper permissions for for your .ssh directory: `chmod 600 ~/.ssh/*` 58 59 ##### Confirm Setup Success 60 Test connectivity to Gerrit by attempting to clone a repo 61 * `git clone ssh://openbmc.gerrit/openbmc/docs` 62 * If successful you should see something like: 63 `Checking out files: 100% (45/45), done.` 64 65 ##### Add Hooks 66 Inside the repo you just cloned, enter the following commands: 67 ``` 68 gitdir=$(git rev-parse --git-dir) 69 scp -p -P 29418 openbmc.gerrit:hooks/commit-msg ${gitdir}/hooks 70 ``` 71 This will enhance the `git commit` command to add a `Change-Id` to your commit 72 message which Gerrit uses to track the review. 73 74 ##### Push Code Change to Gerrit 75 Now that your workstation and Gerrit are configured, you are ready to make code 76 changes and push them to Gerrit for code review. Here is what the basic workflow 77 will look like. 78 * Make your code changes 79 * Add those files to the index to be committed: 80 `git add [file1 file2 ... fileN]` 81 * Commit your changes, adding a Signed-off-by line to it (more on 82 [writing good commit messages](https://github.com/openbmc/docs/blob/master/CONTRIBUTING.md#submitting-changes)): 83 `git commit --signoff` 84 * Push your changes to Gerrit for code review: 85 `git push origin HEAD:refs/for/master` 86 * Go to [Gerrit web interface](https://gerrit.openbmc.org/), click on 87 your new review, and add reviewers based on `OWNERS` file in the repo. 88 89 ##### Conclusion 90 If you've completed all of the above steps successfully, that's it! You have now 91 set up Gerrit and know how to submit your code changes for review! 92 93 Submitting changes for review is just one of many steps in the contributing 94 process. Please see 95 [CONTRIBUTING](https://github.com/openbmc/docs/blob/master/CONTRIBUTING.md) 96 for best practices. 97