GetCodeOwnerStatus: Include reasons for the returned statuses

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.

With this change the GetCodeOwnerStatus REST endpoint returns reasons
for the statuses to the frontend so that they can be shown to the user.

Each status can have multiple reasons, although at the moment we return
at most one reason. It's a list so that we can return further reasons in
future without breaking the API (switching from a single reason to a
list of reasons would be an incompatible change).

At the moment reasons are only set if the status APPROVED or PENDING.
For INSUFFICIENT_REVIEWERS no reason is set as this state is
self-explaining and the reason would be always the same.

The reason 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 accounts that are referenced from the
reasons are returned in the new 'accounts' field in CodeOwnerStatusInfo
so that the frontend has the account data for the referenced accounts
available.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ic478955c51d289828f7b6a507f75d03fc1bf1452
12 files changed
tree: 3fa7734c6ba679456fe6e80e3b4b96b454111007
  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.