0 ratings 0% found this document useful (0 votes) 60 views 3 pages Gerrit Code Review Cheatsheet
Gerrit Code Review Cheatsheet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save Gerrit Code Review Cheatsheet For Later Gerrit Code Review Cheatsheet
e 2
Contributing Patches Updating This
Document
Gerrit Code Review Cheatsheet
Install the commit-msg hook in your repository
-P 29428 username@ectiy s/connit-neg .git/nooks
gerrith:
This will ask for a password. Its the password that you have to generate in the SSH Keys section of settings in your Gerrit,
account,
‘You can alternatively download the file. The hook helps append a Change-Id trailer to your commit message.
EGit can also generate a Gerrit Change-Id into your commit message both manually or in an automated way,
To create a new change
+ Git
naster
To update an existing change with a new commit
HEAD: refe/for/master
‘This works because Gerrit links the new commit to the prior change based upon the Change-Id footer in the commit
message. (This is automatically generated by the commit-msg hook you installed above. If you refuse to use the commit=
msg hook, or don't have a Change-Id footer, you should read the Gerrit documentation on ciange-id lines and replacing
changes.
Note: To be picked up by Gerrit, a Change-Id line must be in the bottom portion (last paragraph) of a commit message, and
may be mixed together with the Signed-off-by, Acked-by, or other such footers, So if your Change-Id line is ignored its
probably not in the last paragraph :).
To compare bulk diffs using Git
Since each Gerrit review patchset actually commis its own tree, you can pull out the trees and compare them.
Iyou've got a large changeset, and you want to be able to do diffs between them via (command line) git instead of browsing
‘on the web, then you can fetch the individual changes and then perform a diff, For example,
httosv/eclipse.gerrthub jo/c/ectipse-jaitjgit/+/2 shows the ‘download’ section for each patchset. In this case, it looks like:
# Patch Set 1 git pull origin refs/changes/02/2/1 (143331a91ba477d3170cde9613576cF968B8ac358)
# Patch Set2 git pull origin refs/changes/02/2/2 (13ah9a43d4d512963556a92—80901 20403228068)
+ Patch Set3 git pull origin refs/changes/02/2/3 (dl4cc645655683pa3e30a25933f022821 4268988)
le8d38Sb614C7214796e1 7
+ Patch Set 4 git pull origin refs/changes/02/2/4 (4 4381 f6e0¢¢25)
Performing a git pul will both get the bits and merge them into your tree, which won't do what you want for comparison.
So, in order to gat the bits (but not merge), you need to doa git Ferch instead. Let's say we want to diff the last two
patches against each other rather than reviewing the entire patchset again:
30a35833%22621426898( 43deBA38SH62 4e72C4Git fetched data will stay around in your repository, but will be ‘orphaned’ if no references point to it, To clean up, you can run
git gc or wait untl this happens automatically.
Trigger Jenkins build for a change
We have build jobs jgit.gerrit on htips://ci.eclipse.org/jgit, and egit-gerrit and egit-github-gerrit on
httpsi/ci eclipse. org/agit! which are triggered automatically when a new change or a new patchset for an existing change is
pushed for review. These jobs wil comment onthe respective change when the buld ie lated and when its finished and
ote onthe change according to the buld and test results,
‘Sometimes you may want to retrigger such a build e.g, because it may have failed due to some temporary problem.
Committers can manually trigger these jobs in the following way:
+ Go to Trigger a Gerrit event manually page
+ Search for a change you'd lke to build
+ Select the patch set(s) you want to trigger
+ Press Trigger Selected button
If you are nat a committer and need to retrigger a build ask for that on the mailing list
To approve a change
+ Click on Publish Comments
+ Vote with the radio buttons,
To add a reviewer
Once you've pushed your commit to Gerrit for review, you can go to the web page ( hitps://eclipse.gerrithub.io) and see your
changes. By clicking on the review, there's an option to add a reviewer by e-mail address; they'll then be sent a message
indicating that they'd Ike your review on the item.
Its usually not necessary to add any reviewers, it should be reviewed by the committers sooner or later. If this hasn't
happened, you can look for people that did changes in the same area and add them as reviewers. I's also ok to comment on
‘a change to "bump" its visibility.
Code Review
‘The code review category indicates your opinion on the quality of the code, and how well t fits within the purpose of the
‘existing surrounding code. A +2 vote from any committer is required before submission can occur. A-2 vote from any
committer will Block submission,
Submission Guidelines
We strive to use Gerrit to improve our understanding of the code base and improve quality.
In order to ensure a proper review happens, some simple guidelines should be followed:
* vote 0/-1 for not-ready-to-submit (AKA WIP) own proposals, +1 otherwise;
+ If a changeset is not-ready-to-submit, please put [RFC] or [DRAFT] in the message to let people know
+ let non-trivial changes be in review for at least 24 hours
+ ifyou want your changeset reviewed by someone, please add them as a reviewer
Tips & Tricks
Class Loading Issues
Ifyou encounter strange class loading issues during runtime (e.g. on Ul test executions) the following might help:
Enable tracing in your launch configuration to get information how imported packages are resolved at runtime, Select the
‘Tracing tab in your launch configuration, select "Enable tracing", select plug-in org.eclipse.osgi, select category
resolveriwiring on the right side.
Category:Draft Documentation
© i Ee
Contributing Patches Updating ThisDocument