Fix negated label: queries with external groups

The ChangeIndexPostFilterPredicate approach doesn't fix the case where
the operator is also negated. For example if there was a query like
`status:open NOT label:Code-Review=1,group=ldap/testers` then in that
scenario we tried to index match Code-Review+1 votes and expected that
we would use post-filtering for the group. However, since the operator
was negated, we excluded those changes from the results before we
reached the post-filter stage, meaning we never include changes where
the voter isn't in the given group.

This solution is an unoptimized approach that avoids using the index for
the label operator whenever an external group is given. A better
approach would fix the negation case for any
ChangeIndexPostFilterPredicate, but that looks to be much more
complicated to implement.

Avoiding duplicated code is tricky here since the PostFilter and Index
predicates need to extend different classes, but share almost all of the
same logic for match(). Using a static inner helper class 'Matcher'
as a member of both the PostFilter and Index classes seems to be the
simplest way to minimize the duplication. Additionally we can extend
that helper class in each of the PostFilter/Index classes within
MagicLabelPredicates because they need slightly different behavior for
one method.

The added tests pass with both the Lucene and FakeIndex implementations,
but the FakeIndex also passes without the fix because it uses match()
instead of doing some kind of index search operation.

Release-Notes: Fixed bug with negated label: operator using an external group
Change-Id: I0268476f0e6e3008d30ce49dfbb71ea3b093f7c1
6 files changed
tree: 27ba99a274f7068d108993c84a30f02cf8e5828e
  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.