Gerrit/Web tutorial

From mediawiki.org

You can create, modify, and merge requested changes to a repository using the Gerrit website. This is a tutorial describing how to do these things.

Create a change[edit]

If you're logged in to Gerrit, you can create code changes directly within the web interface. This can be useful for making small patches, or for non-developers to contribute small fixes.

  1. Go to https://gerrit.wikimedia.org/r/admin/repos/ and choose the code repository that you want to edit.
  2. Select "Commands" in the sidebar
  3. Click "Create Change"
  4. Set branch to "master" (if you don't want to use master branch you can use the other branches available for that project)
  5. Set the topic to something of your choosing (e.g. "copy-edit" - must be all-one-string) (optional)
  6. Write a description ("commit summary") in the big text field by following message guidelines. (Example)
  7. Click "Create"
  8. In the upper right corner, click the "Edit" button
  9. Under "Files", click "ADD/OPEN/UPLOAD" button
  10. Type the folder/file path for the file you wish to edit (e.g. i18n/en.json) and click "Confirm"
  11. Find the line(s) you want to change, and change them.
  12. Click "Save"
  13. Click "Close"
  14. Click "Publish edit"
  15. Click "Mark as active" to remove the "Work in Progress" status from your code changes

Modify a change[edit]

To modify the files in a change, first click "Edit" in the upper right.

Then, to edit a file in a change, click "Actions" to the right of the file in the list and click "Add/Open/Upload".

To add a file to a change, click "ADD/OPEN/UPLOAD" under "Files".

When you're done, click "Stop Editing" in the upper right.

Comment on a file[edit]

Under Files, Expand All opens the diff for each file below. You can double-click on a line and then press the C key to comment on that line, then click "Save" to save the draft comment. Then, at the top of the page click the "Reply" button to publish your comment.

Parts of a change[edit]

The change has a few fields, links and buttons:

  • Assignee. An optional field to make a single person responsible for handling reviewing the changeset. This should only be set if the assignee has agreed.
  • Reviewers. 'jenkins-bot' is the autoreviewer that auto-verifies anything that passes the Jenkins tests. It will report a red or green mark depending on whether the build passes.
  • The "Add reviewer" button under Reviewers: in the upper left corner manually request review from someone. It'll show up in their Gerrit dashboard.
  • Reply adds your comments to a changeset, including an overall comment and/or inline comments you added (see above).
    • If, upon code review, you approve, use "Code-Review: +1" under "Reply"; otherwise, use "Code-Review: -1" to disapprove. These numbers are nonbinding, won't cause merges or rejections, and have no formal effect on the code review.
  • Abandon (you'll see this if you created this change). This action removes the change from the list to review, but leaves it in Gerrit for archival purposes.
  • The "Only Comments" switch allows to hide reviews by non-human bots. See phab:T48148#6294913 for an example.

Comparing patch sets[edit]

Every time you amend your commit and submit it for review, a new patch set is created. You can compare the different patch sets like this:

  • Under Files, select either Expand All or choose a specific file listed to open that file.
  • On the left side under Patch Set, Base is preselected. On the right of the screen under Patch Set, the latest patch set is preselected. Adjust the selected patch sets to your needs.

Formally reviewing and merging or rejecting the change[edit]

If you are one of the Gerrit project owners, you'll also see:

  • Abandon button
  • under Reply, additional Code-Review options to +2 (approve) or -2 (veto) a diff, and a Post button (publish your comment and merge diff into the branch, in 1 step)
  • Submit button (merge -- only useful if you or someone else has already given a +2 approval to the diff, but not merged it)

And once you've merged something into the example Gerrit project you'll see it in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/examples/.

If you merged a commit that references a task in Phabricator and that commit is supposed to fix that task completely, please go to that task and change its status to "Resolved" (via the Add Action… 🡒 Change Status dropdown). Also reference the merge ID if gerritbot has not already posted it in that task.