commit | fe92903b1ab0cb551a31d9b6ee07e370965ab07a | [log] [tgz] |
---|---|---|
author | Edwin Kempin <ekempin@google.com> | Tue Oct 25 14:20:37 2022 +0200 |
committer | Edwin Kempin <ekempin@google.com> | Fri Oct 28 11:52:57 2022 +0200 |
tree | 4f572b61bba0e5c80adec531eef7a9bb4ebc2339 | |
parent | 9b0aec01bc9ec61b3145f73aabf212bb3ecba7d8 [diff] |
CodeOwnerApprovalCheck: Factor out computation of input data The CodeOwnerApprovalCheck class is quite large which makes the class difficult to read. To make it smaller we factor out the computation of all input data that this required for checking the code owner approvals of a change. The input data is now represented by the new CodeOwnerApprovalCheckInput class which is an immutable AutoValue class. The loading of the input is done by the CodeOwnerApprovalCheckInput.Loader class (e.g. this class computes the relevant reviewers and approvers, loads the global code owners and fallback code owners from the config etc.). The Loader class needs to get some classes injected which is why we have a Factory to create it. Having a class that represents all inputs, make it easier for CodeOwnerApprovalCheck to pass down the input through the methods that do the computation (just pass 1 parameter instead of n parameters). In addition to checking code owner approvals on a change CodeOwnerApprovalCheck also computes owned paths for a set of users. This is achieved by using the same algorithm, but with specially constructed inputs. By having the CodeOwnerApprovalCheckInput class we can make the creation of the input for this purpose more explicit. In future we need additional inputs for the code owner approval check (e.g. approvals on previous patch sets for making code owner approvals sticky on file level). Adding these additional inputs is easier now that we have CodeOwnerApprovalCheckInput, otherwise we would need to add even more logic to the already large CodeOwnerApprovalCheck class. This change is a pure refactoring. This means no behavior is changed. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I298f8e3b6acd7afdec900e1c1fde6d1f26ed1a06
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.
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
.