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 23Create keys: ```ssh-keygen -t rsa -C "your_email@your-domain"``` 24* Recommended to use the defaults instead of picking your own directory/file 25 names. 26 27Add Keys to GitHub: 28* <https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/> 29 30Add Keys to OpenBMC's Gerrit Server: 31* Login to [Gerrit](https://gerrit.openbmc-project.xyz/) with your GitHub 32 account. 33* Go to 34 <https://gerrit.openbmc-project.xyz/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-project.xyz/) 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 SSH config entry 44Add the following to `~/.ssh/config`: 45``` 46Host openbmc.gerrit 47 Hostname gerrit.openbmc-project.xyz 48 Port 29418 49 User <Your Gerrit Username> 50``` 51* **NOTE**: There is a bug in AFS that requires `AFSTokenPassing no` to be 52 added to the SSH entry if using AFS. 53* Your Gerrit Username can be found in Gerrit under Settings -> Profile -> Username 54* Ensure proper permissions for for your .ssh directory: `chmod 600 ~/.ssh/*` 55 56##### Confirm Setup Success 57Test connectivity to Gerrit by attempting to clone a repo 58* `git clone ssh://openbmc.gerrit/openbmc/docs` 59* If successful you should see something like: 60 `Checking out files: 100% (45/45), done.` 61 62##### Add Hooks 63Inside the repo you just cloned, enter the following commands: 64``` 65gitdir=$(git rev-parse --git-dir) 66scp -p -P 29418 openbmc.gerrit:hooks/commit-msg ${gitdir}/hooks 67``` 68This will enhance the `git commit` command to add a `Change-Id` to your commit 69message which Gerrit uses to track the review. 70 71##### Push Code Change to Gerrit 72Now that your workstation and Gerrit are configured, you are ready to make code 73changes and push them to Gerrit for code review. Here is what the basic workflow 74will look like. 75* Make your code changes 76* Add those files to the index to be committed: 77 `git add [file1 file2 ... fileN]` 78* Commit your changes, adding a Signed-off-by line to it (more on 79 [writing good commit messages](https://github.com/openbmc/docs/blob/master/CONTRIBUTING.md#submitting-changes)): 80 `git commit --signoff` 81* Push your changes to Gerrit for code review: 82 `git push origin HEAD:refs/for/master` 83* Go to [Gerrit web interface](https://gerrit.openbmc-project.xyz/), click on 84 your new review, and add reviewers based on `MAINTAINERS` file in the repo. 85 86##### Conclusion 87If you've completed all of the above steps successfully, that's it! You have now 88set up Gerrit and know how to submit your code changes for review! 89 90Submitting changes for review is just one of many steps in the contributing 91process. Please see 92[CONTRIBUTING](https://github.com/openbmc/docs/blob/master/CONTRIBUTING.md) 93for best practices. 94