Disable OWNERS validation that cannot be satisfied for merge commits

When OWNERS files are modified the validation verifies that newly added
imports can be resolved. If an OWNERS file imports an OWNERS file from
another project without specifying the source branch it assumed that the
OWNERS file should be imported from the same branch in which the
importing OWNERS file is contained. E.g. if an OWNERS file in project A
in branch master contains "file:B:foo/OWNERS" (import 'foo/OWNERS' from
project B) 'foo/OWNERS' is imported from the master branch in project B.
If that OWNERS file in project A gets merged into another branch, e.g.
the 'release' branch, then the same import "file:B:foo/OWNERS" imports
'foo/OWNERS' from the release branch in project B. If the validation
rejects such imports if they are not resolvable (e.g. the imported
OWNERS file doesn't exist) this can enforce landing merges in a certain
order or even make landing merges impossible.

Example 1:
1. project A adds foo/OWNERS
2. project B imports A:foo/OWNERS
=> If these changes should be merged into another branch (e.g. a release
branch) the validation of the code owner config files only succeeds if
the merges are done in the correct order (1. do merge for project A, 2.
do merge for project B). If the merges are done in the opposite order
(1. do merge for project B, 2. do merge for project A) the code owner
config file validation for the merge in project B would fail since
A:foo/OWNERS doesn't exist in the target branch yet.

Example 2:
1. project A adds foo/OWNERS
2. project B imports A:foo/OWNERS
3. project B adds bar/OWNERS
4. project A imports B:bar/OWNERS
=> If the merge for project A is done first the code owner config file
validation would fail because B:bar/OWNERS doesn't exist yet. If the
merge for project B is done first the code owner config file validation
would fail because A:foo/OWNERS doesn't exist yet.

To make the landing of merges possible in this case, we now report
non-resolvable imports that are newly added in merge commits as warnings
if the import is done from another branch and the branch is not
specified but assumed to be the same as the branch that contains the
importing OWNERS file. In contrast to errors, warnings do not lead to a
rejection of the commit, but are purely informational.

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