Allow to disable the validation of code owner config files per branch

Being able to skip the validation on some branches is useful for
branches that are fully operated by bots. Bots cannot fix code owner
config files and any issue that blocks them from uploading/submitting is
more severe than an invalid code owner config file. So it's better to
allow invalid code owner config files and fix them at a later point in
time.

Whether code owner config files are validated on commit received and
submit can be controlled on project-level by setting
`codeOwners.enableValidationOnCommitReceived` and
`codeOwners.enableValidationOnSubmit` in code-owners.config.

With this change we now add a possibility to override this configuration
on branch-level by setting
`validation.<branch>.enableValidationOnCommitReceived` and
`validation.<branch>.enableValidationOnSubmit` in code-owners.config.

As all configuration parameters the new configuration parameters are
inherited from parent projects if not set. An inherited branch-level
configuration also overrides a local project-level configuration. This
allows to exempt branches globally from code owner config validations.

'<branch>' can be an exact ref, a ref pattern (e.g. "refs/heads/*") or a
regular expression (e.g. "^refs/heads/.*"). If a branch is matched by
multiple validation subsections it is undefined which subsection takes
precedence. This is because Config#getSubsections returns a Set which
doesn't preserve the order in which subsections appear in the config
file.

In contrast to other configuration parameters branch-level validation
parameters can only be set in code-owners.config, but not in
gerrit.config (because as plugin we cannot have subsections in
gerrit.config). This means to exempt branches globally the configuration
needs to be done in the code-owners.config of the All-Projects project.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ifaa955d56fa499c440ee338ef4c0f40b495a2542
9 files changed
tree: 0f028695e0458e1fa5e5d08371168561a5580651
  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.