When listing code owners for a path let callers know if all users own it

Adds a ownedByAllUsers boolean field to CodeOwnersInfo which is returned
by the get code owners REST endpoints (GetCodeOwnersForPathInChange and
GetCodeOwnersForPathInBranch).

This allows callers to know if a path is owned by all users. E.g. the
Gerrit frontend should make this transparent to users when suggesting
code owners.

In order to know whether a path is owned by all users we need to
continue inspecting code owner configs in parent folders even if we have
already found enough code owners to satisfy the requested limit, as
parent code owner configs may assign code ownership to all users, which
we need to know in order to populate the ownedByAllUsers field in the
response. We can still abort the iteration over code owner config files
if we have already found that the path is owned by all users.

Needing to check all relevant code owner config files if paths are not
owned by all users means that the get code owners calls become a bit
more expensive, but it shouldn't be significantly slower. If performance
becomes an issue we need to implement caching for code owner configs.

FWIW if we ever add further scores for code owners (besides the distance
score), which we likely will do,  we also need to iterate over all
relevant code owner configs. So iterating over all code owner configs
already now, shouldn't be an issue.

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