PathCodeOwnerStatus: Include a reason explaining the status

The functionality of the code-owners plugin has grown over time and
there are more and more possibilities how files can get code owner
approved (e.g. explicit approval by regular/default/fallback/global code
owner, implicit approval by regular/default/fallback/global code owner,
override, exempted user, exempted pure revert).

At the moment the UI is only showing the code owner status for files,
but doesn't tell the user the reason for the state. Since there a many
different reasons for the same state, users have a hard time
understanding the state. To address this we want to show the user a
reason for the state that explains why it was set.

As a first step towards this PathCodeOwnerStatus can now contain a list
of reasons explaining the state. The reasons are populated by
CodeOwnerApprovalCheck when the status is set to APPROVED or PENDING
(for INSUFFICIENT_REVIEWERS no reason is set as this state is
self-explaining and the reason would be always the same).

PathCodeOwnerStatus accepts a list of reasons, but for now we are at
most setting a single reason. It's a list so that we can easily expand
this in the future if necessary. Having it as a list already now will be
important for the REST API where we cannot make incompatible changes
like switching from a single reason to a list of reasons.

Reasons are messages that can be shown to the user. These messages can
reference accounts via the same placeholders that are also used in
change messages. The frontend needs to replace the placeholders before
showing the reason messages to the user. The usage of placeholders,
instead of hard-coding the user names, allows the frontend to use
dedicated controls for showing the account information (e.g. show the
user name, but make additional account information available via a
hovercard).

The following next steps will be implemented in follow-up changes:
1. Return the reasons to the caller (extend the JSON entities to include
   the reasons and the account infos).
2. Extend the frontend to show the reasons to the user.

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