Fix submit rule for changes for which the target branch doesn't exist

There are 2 possibilities to have changes where the target branch
doesn't exist:

1. An initial commit is pushed for review to the not yet created master
   branch (that's a hard-coded special case where Gerrit allows
   uploading a change for an unborn branch).

2. A change is created for an existing branch and the branch gets
   deleted afterwards.

At the moment the code owner submit rule returns not ready in this case.

Since the target branch of the change doesn't exist it cannot contain
OWNERS files that define code owners. However it is possible that there
are default code owners (defined in refs/meta/config), global code
owners (defined in code-owners.config) or fallback code owners
(configured via code-owners.config) that could approve the change. In
addition there can be a code owner override that code-owner-approves the
change.

Now, if the target branch doesn't exist, CodeOwnerApprovalCheck skips
checking code owners from OWNERS files in the target branch, but still
checks default, global and fallback code owners, as well as overrides.

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

JavaScript Plugin

For testing the plugin with Gerrit FE Dev Helper build the JavaScript bundle and copy it to the plugins/ folder:

bazel build //plugins/code-owners/ui:code-owners
cp -f bazel-bin/plugins/code-owners/ui/code-owners.js plugins/

and let the Dev Helper redirect from .+/plugins/code-owners/static/code-owners.js to http://localhost:8081/plugins_/code-owners.js.