GetChange: provide meta=SHA1 option

This change lets callers inspect a change at a given NoteDb commit.

    $ curl -u admin:secret http://localhost:8080/a/changes/101/'?pp=1&O=22'
    ..
      "current_revision": "f3cccef96155ed3f9de2aaed44d8cf00960a21ca",
      "revisions": {
        "f3cccef96155ed3f9de2aaed44d8cf00960a21ca": {
          "kind": "REWORK",
          "_number": 5,

    $ curl -u admin:secret http://localhost:8080/a/changes/101/'?pp=1&O=22&meta=8ebdac0e8a2047ee2d2433a09f05de230d3050f2'
    ..
      "current_revision": "e24af8d95295181064078a99a3bde31cf9b643a2",
      "revisions": {
        "e24af8d95295181064078a99a3bde31cf9b643a2": {
          "kind": "NO_CODE_CHANGE",
          "_number": 3,

This is part of an alternate approach to event notifications, where
notification is split into two parts:

1) notifying a client that *something* changed

2) letting the client discover precisely *what* changed.

This change provides a way for clients to get 2): A subscriber, when
receiving a notification, can use /changes/ID?meta=XXX to get the old
and new states of the ChangeInfo. By analyzing the difference between
both ChangeInfos, subscribers can tell what happened.

As a follow-up, we plan to provide a diffing functionality as a
built-in REST endpoint.

If the server hasn't seen the NoteDb meta SHA1 yet, it replies with
412. This is useful in a distributed setting: notifications can be
delivered ahead of the underlying Git data. If this happens, this also
results in a 412 error code. The client can respond by waiting and
retrying.

For 1), the minimal amount of information required is a list of opaque
identifiers (change number, old meta SHA1, new meta SHA1).

The opaque identifiers could be discovered through several means

* By finding recently modified changes, through a query such as
  "age:1h status:open", and comparing the meta SHA1s with output of an
  earlier query

* By executing ls-remote, and comparing its output with an earlier
  run.

* By hooking into ref updates at the storage level, and exposing the
  result over SSH. For vanilla JGit, this will need JGit changes,
  because RefChangedEvent in JGit doesn't provide per-Ref data.

  At Google, the plan is to generate these notifications at the storage
  level in the global ref database.

This approach to notifications has several advantages over the
existing stream-events mechanism:

* The event notification only contains opaque data, and can be sent to
  any subscriber without leaking data. The GetChange endpoint enforces
  visibility.

* It uses the same endpoint as the UI, so there is no chance of new
  features being forgotten for stream-events (for example, stream-events
  does not support attention set updates).

* It doesn't rely on having a stream. Without streaming, the
  change index (query "status:open age:INTERVAL") or the output of ls-remote
  can still provide data on for polling clients.

* A subscriber can protect against missed notifications, by keeping
  track of the meta SHA1s locally. If the connection breaks, they can
  resynchronize using the mechanism for polling clients.

Change-Id: Ia54acb37e1187bc64e190d5694de0b17674595f8
8 files changed
tree: 5a9851755ecb9e32f7871e6960bd0a4f940c7d24
  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. .mailmap
  29. .pydevproject
  30. .zuul.yaml
  31. BUILD
  32. COPYING
  33. INSTALL
  34. Jenkinsfile
  35. package.json
  36. README.md
  37. SUBMITTING_PATCHES
  38. version.bzl
  39. WORKSPACE
  40. 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.