Working with Gerrit (For Developers)

Gerrit is a change-based code review system. Instead of reviewing massive branch diffs, Gerrit tracks individual commits as independent, reviewable Changes.


1. Setting Up the commit-msg Hook

Gerrit uses a unique Change-Id footer in each commit message to track changes across multiple revisions (patchsets).

Install the commit-msg hook into your local Git clone:

# Download and install the commit-msg hook
curl -Lo .git/hooks/commit-msg https://<workspaceId>.wharby.dev/tools/hooks/commit-msg
chmod +x .git/hooks/commit-msg

Now, every commit you make will automatically include a Change-Id: line at the bottom of the commit message.


2. Pushing Changes for Review

To push a commit to Gerrit for code review on the main branch, push to refs/for/main:

# Push your local commit to Gerrit review pipeline
git push origin HEAD:refs/for/main

Gerrit will output a direct URL to your Change in your terminal:

remote: Processing changes: new: 1, done    
remote: 
remote: SUCCESS
remote:   https://acme.wharby.dev/c/my-repo/+/101 feat(auth): add sso login [NEW]

3. Uploading New Patch Sets

When a reviewer asks for changes or when fixing CI failures:

  1. Make your code adjustments locally.
  2. Amend your commit (git commit --amend) — keep the existing Change-Id intact.
  3. Push to refs/for/main again:
git add -u
git commit --amend
git push origin HEAD:refs/for/main

Gerrit automatically detects the matching Change-Id and creates Patch Set 2 on your existing review! Reviewers can diff Patch Set 1 vs Patch Set 2 directly to see exactly what changed in response to their feedback.


4. Gerrit Voting & Scorecards

Gerrit uses explicit numerical voting scorecards:

Label Score Meaning
Code-Review +2 Approved: Change looks great and is ready to submit
Code-Review +1 Looks good to me, but someone else must approve (+2)
Code-Review -1 I would prefer that you did not submit this
Code-Review -2 Do not submit (hard veto)
Verified +1 Automated CI checks / tests passed successfully
Verified -1 CI checks failed

Once a change has Code-Review +2 and Verified +1, the author or reviewer clicks Submit to merge the commit into the target branch.