Allow to define default code owners across branches in refs/meta/config

It is now possible to define default code owners across branches in a
code owner config file in the root directory of the refs/meta/config
branch.

The code owner config file in refs/meta/config is the parent code owner
config of the root code owner configs in all branches. This means it is
ignored if the root code owner config file in a branch has "set
noparent" set.

Being able to define code owners across branches is useful to:

* keep default code owners consistent across all branches (e.g. if a new
  default code owner should be added it can be done in the one code owner
  config file in refs/meta/config rather than needing to update the root
  code owner config files in all branches)

* initially setup code owners for a repository (e.g. just define the
  default code owners in refs/meta/config instead of needing to add a
  root code owner config file in all branches)

Default code owners are not inherited from parent projects. If code
owners should be defined for child projects, this is already possible
via global code owners.

The following changes have been done:

* CodeOwnerConfigHierarchy:
  Iterates over the code owner config files that apply for a path. This
  includes the default code owner config file in refs/meta/config now,
  which is the parent of the root code owner config file.

* CodeOwnerConfigScanner:
  Scans the code owner config files in a branch. This class has now an
  option to control if the default code owner config file in
  refs/meta/config should be included:

** We include the default code owner config file in refs/meta/config to
   decide whether we are in bootstrapping mode, as this file applies to
   the branch and we want to use the bootstrapping mode only if there is
   no applying code owner config file.

** We do not include the default code owner config file in
   refs/meta/config if the code owner config files in a branch should be
   listed or checked, as this would be unexpected.

* AbstractGetCodeOwnersForPath:
  Suggests code owners. Code owners from the default code owner config
  file in refs/meta/config are included into the suggestion. They have a
  distance that is by 1 higher than the distance of code owners that are
  defined at the root, and by 1 lower than the distance of the global
  code owners that are defined via configuration.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I472a5239246970f240aa1828e31374b3d7cd086e
19 files changed
tree: 49127384f4c37e2e8d8c358621573f367f110ff0
  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