Disable rename detection for the code owners submit rule

The code owners submit rule only checks if all paths (new and old) have
been code owner approved (see CodeOwnerApprovalCheck#isSubmittable). For
this it's OK if for renamed files 2 FileCodeOwnerStatus'es are returned
(one for the new path and one for the old path), hence rename detection
can be disabled here.

When code owner statuses are returned from the GetCodeOwnerStatus REST
endpoint however we must detect renames (see
CodeOwnerApprovalCheck#getFileStatusesAsSet) because our API
documentation for this REST endpoint says that we return a single code
owner status for renamed files. This is important for callers that do
pagination, e.g. if the change screen shows the first 200 files (which
may include renames) than getting the first 200 code owner statuses
should match these files (their new and old paths).

Changing CodeOwnerApprovalCheck#getAllPathsAsApproved to always disable
the rename detection didn't make any tests fail although it affects the
GetCodeOwnerStatus REST endpoint. This was because getAllPathsAsApproved
is only called from the GetCodeOwnerStatus REST endpoint if a change
contains a renamed file and all files of the change are exempted from
requiring code owner approvals because a) the uploader is exempted from
requiring code owner approvals or b) the change is a pure revert and
pure reverts are configured to not require code owner approvals. The new
tests in GetCodeOwnerStatusIT cover this now.

CodeOwnerApprovalCheck has one more caller of ChangedFiles for which we
haven't checked yet whether rename detection can be disabled. At this
place we add a TODO so that we remember to check this later.

Bug: Google b/461456634
Change-Id: I9fc7ca3a808a176324fc9eb2f1d49b4bb4b55cae
Signed-off-by: Edwin Kempin <ekempin@google.com>
4 files changed
tree: ac446260ae3d6af8a36c61e25d8d8620709f5c27
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. web/
  6. .gitignore
  7. .gitreview
  8. BUILD
  9. LICENSE
  10. 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.

For a detailed description of the plugin functionality please refer to the plugin documentation.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide.

NOTE: The plugin documentation only renders correctly when the plugin is installed in Gerrit and the documentation is accessed via https:///plugins/code-owners/Documentation/index.html. If you want to read the documentation before installing the plugin, you can find it properly rendered here.

JavaScript Plugin

From the root of the gerrit repository.

bazel test //plugins/code-owners/web:karma_test

For testing the plugin with the Gerrit FE Dev Helper the command below builds

    bazel build //plugins/code-owners/web:code-owners
    ln -s bazel-bin/plugins/code-owners/web/code-owners.js polygerrit-ui/app/plugins/

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