Return reviewer updates for reviewers by email in change details (part 1/2)

ChangeInfo that is returned to the frontend when it requests change
details contains reviewer updates as ReviewerUpdateInfo's.

The frontend relies on getting ReviewerUpdateInfo to show reviewer
updates in the Change Log (the change messages that Gerrit adds for
reviewer updates are filtered out since they are tagged with
"autogenerated:...").

So far Gerrit only returns reviewer updates for reviewers that are
Gerrit accounts but not for reviewers by email. Due to this updates
about reviewers by email are missing in the Change Log.

Reviewer updates are recorded in NoteDb and ChangeNotesParser parses
them from there. At the moment ChangeNotesParser only creates
ReviewerStatusUpdate's for reviewers that are Gerrit accounts (method
parseReviewer), but not for reviewers by email (method
parseReviewerByEmail).

In NoteDb reviewers that are Gerrit accounts are recorded as account
IDs and reviewers by email are recorded as Address strings, consisting
out of a full name and an email ("Full Name <full.name@example.com>")
or only an email ("Full Name <full.name@example.com>").

ReviewerStatusUpdate currently refers to the reviewer by account ID
(field reviewer). To be able to also refer to reviewers by email, we
make the account ID optional (we change the type of reviewer field from
Account.Id to Optional<Account.Id>) and we add a new optional field for
the reviewer address (we add a new reviewerByEmail field of type
Optional<Address>).

ReviewerStatusUpdate's are a part of ChangeNotesState that is converted
into a proto to be cached. This means the changes to
ReviewerStatusUpdate must be reflected in the ReviewerStatusUpdateProto
proto.

In the ChangeNotesStateProto optional fields are accompanied by a "has"
boolean field that tells whether the optional field has been set (see
comment on ChangeNotesStateProto). This means to make the
ReviewerStatusUpdateProto.reviewer field optional we add a boolean
ReviewerStatusUpdateProto.has_reviewer field. For storing reviewers by
email we add a ReviewerStatusUpdateProto.reviewer_by_email field and a
ReviewerStatusUpdateProto.has_reviewer_by_email field.
ChangeNoteState.toReviewerStatusUpdateProto takes care to populate the
new fields.

When rolling out this change at Google we must ensure that:
1. the new code can read old protos
2. there are no new protos that the old code cannot read, until all
   datacenters have been updated with the new code

1. is ensured in ChangeNotesState.toReviewerStatusUpdateList that reads
the reviewer field if neither has_reviewer_by_email nor has_reviewer
have been set, which is the case for old protos.

2. is ensured by not creating any ReviewerStatusUpdate for reviewers by
email yet (see code in ChangeNotesParser.parseReviewerByEmail that is
commented out). This means all ReviewerStatusUpdate's still have the
reviewer field set which is unconditionally read by the old code.

Creating ReviewerStatusUpdate's for reviewers by email will be done by
the follow-up change (uncomment the code in
ChangeNotesParser.parseReviewerByEmail). That change must only be
submitted after this change has been rolled out to all datacenters, so
that all datacenters have the new code and can read the new protos.

Finally, ChangeJson is updated to be able to emit ReviewerUpdateInfo's
for reviewer updates that are done for reviewers by email, and hence
have no account ID. ChangeJson already had code to create AccountInfo's
for reviewers by email that only have the name and email set, but no
account ID. We refactored this a bit so that we can use this code to
create the AccountInfo's in ReviewerUpdateInfo for reviewer updates that
are done for reviewers by email.

A new test in ChangeReviewersByEmailIT, checks that still no reviewer
updates for reviewers by email are returned, but the assertions for when
we can enable this are already prepared as comments. The new test
follows the example of the test that checks reviewer updates for
reviewers that are Gerrit accounts (see
ChangeReviewersIT.addReviewerToReviewerUpdateInfo()).

Release-Notes: skip
Bug: Google b/240676565
Forward-Compatible: checked
Change-Id: If1dfb3c710b5fbd9babddc669cfc85020dab14fd
Signed-off-by: Edwin Kempin <ekempin@google.com>
9 files changed
tree: 072d25873739ec51ad0ce6a9223b730734b955bb
  1. .settings/
  2. .ts-out/
  3. antlr3/
  4. contrib/
  5. Documentation/
  6. e2e-tests/
  7. java/
  8. javatests/
  9. lib/
  10. modules/
  11. plugins/
  12. polygerrit-ui/
  13. prolog/
  14. prologtests/
  15. proto/
  16. resources/
  17. tools/
  18. webapp/
  19. .bazelignore
  20. .bazelproject
  21. .bazelrc
  22. .bazelversion
  23. .editorconfig
  24. .git-blame-ignore-revs
  25. .gitignore
  26. .gitmodules
  27. .gitreview
  28. .pydevproject
  29. .zuul.yaml
  30. BUILD
  31. COPYING
  32. INSTALL
  33. Jenkinsfile
  34. MODULE.bazel
  35. package.json
  36. README.md
  37. SUBMITTING_PATCHES
  38. version.bzl
  39. web-dev-server.config.mjs
  40. WORKSPACE
  41. yarn.lock
README.md

Gerrit Code Review

Gerrit is a code review and project management tool for Git based projects.

Build Status Maven Central

Objective

Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.

Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.

Documentation

For information about how to install and use Gerrit, refer to the documentation.

Source

Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.

Reporting bugs

Please report bugs on the issue tracker.

Contribute

Gerrit is the work of hundreds of contributors. We appreciate your help!

Please read the contribution guidelines.

Note that we do not accept Pull Requests via the Github mirror.

Getting in contact

The Developer Mailing list is repo-discuss on Google Groups.

License

Gerrit is provided under the Apache License 2.0.

Build

Install Bazel and run the following:

    git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
    cd gerrit && bazel build release

Install binary packages (Deb/Rpm)

The instruction how to configure GerritForge/BinTray repositories is here

On Debian/Ubuntu run:

    apt-get update && apt-get install gerrit=<version>-<release>

NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.

On CentOS/RedHat run:

    yum clean all && yum install gerrit-<version>[-<release>]

On Fedora run:

    dnf clean all && dnf install gerrit-<version>[-<release>]

Use pre-built Gerrit images on Docker

Docker images of Gerrit are available on DockerHub

To run a CentOS 8 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-centos8

To run a Ubuntu 20.04 based Gerrit image:

    docker run -p 8080:8080 gerritcodereview/gerrit[:version]-ubuntu20

NOTE: release is optional. Last released package of the version is installed if the release number is omitted.