CodeOwnerApprovalCheck: Avoid double instantiation of PathCodeOwners

For every file touched in a change CodeOwnerApprovalCheck visits the
relevant code owner config files to compute path code owners.

This computation was done twice:

1. Once in CodeOwnerConfigHierarchy#visit which iterates over the
   relevant code owner config files for a path

2. Once in CodeOwnerResolver#resolvePathCodeOwners (invoked in
   CodeOwnerApprovalCheck#getCodeOwners which got called from the
   callback that is invoked from 1).

Now instead of instantiating PathCodeOwners again at 2. modifiy the
callback in 1. so that it provides the PathCodeOwners instance instead
of the plain CodeOwnerConfig.

There are other callers of 1. that only need the CodeOwnerConfig (and
not the PathCodeOwners). For them we keep the old callback that provides
CodeOwnerConfig, but now it's only a wrapper around the callback that
provides PathCodeOwners.

CodeOwnerResolver#resolvePathCodeOwners can be invoked either with a
CodeOwnerConfig (as before, still used by other callers) or with
PathCodeOwners (if PathCodeOwners are available this is preferred as it
avoids re-instantiating PathCodeOwners).

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ic092c3dbb6b98cd9490893a05747a6fd48d17d57
6 files changed
tree: 42489e40b137beb6390376b78d94e33189cd3a4c
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.