| commit | 9d2aab0a3a6c0b094366720acdbabcac71a5b9b0 | [log] [tgz] |
|---|---|---|
| author | Edwin Kempin <ekempin@google.com> | Thu Aug 01 11:14:46 2024 +0000 |
| committer | Edwin Kempin <ekempin@google.com> | Fri Aug 02 07:03:37 2024 +0000 |
| tree | b24c21b33fbbff45ad9803bfda4d286f5a890532 | |
| parent | 7bf7837120b194ff653c4b269d9ea28ee5678df4 [diff] |
Return web links for OWNERS files when listing code owners When listing code owners the response contains the code owner config files (e.g. OWNERS files) that have been inspected to gather the code owners. Knowing the inspected code owner config files is important if you want to verify that the correct code owners have been returned or if you want to understand why a certain expected code owner was not included, as in this case you want to look into these code owner config files to see which code owners and rules they define. So far, we returned the project, branch and path for the code owner config files, which is sufficient to locate the code owner config files, but assembling the links to the code owner config files from this information is cumbersome and can take significant time, especially if you need to inspect multiple code owner config files. To save this effort we now return file web links for the code owner config files. Having file web links available makes the lookup of code owner config files much easier, as they contain the direct URLs to the code owner config files. Note that file web links are only available if they are configured. CodeOwnerConfigFileJson is the class that writes the JSON for the returned code owner config files. In this class we need to set the new CodeOwnerConfigFileInfo.webLinks field. To create the file web links we need the project, branch and path of the code owner config file, but also the revision from which it was read. The revision was not available in CodeOwnerConfigFileJson since it only got the CodeOwnerConfig.Key as input which doesn't contain the revision. To make the revision available we have to provide CodeOwnerConfig instead of CodeOwnerConfig.Key. CodeOwnerConfigFileJson also gets imported code owner config files as input which are formatted in the same way as the importing code owner config file. To include web links for them too CodeOwnerConfigImport needs to be extended to contain CodeOwnerConfig, which contains the revision, instead of only CodeOwnerConfig.Key. Since some imports can be unresolved (e.g. an import that references an non-existing code owner config file) the imported CodeOwnerConfig in CodeOwnerConfigImport is optional (i.e. it is not set for unresolved imports). This means, if an import is unresolved no web links are returned for it. Due to CodeOwnerConfigImport needing the imported CodeOwnerConfig for resolved imports now, we need to provide it in PathCodeOwners which is responsible for resolving the imports and also in quite some tests. Bug: Google b/345161989 Change-Id: If7efad1ffaf456a192ccea2e09d76b19d8f3b4fa Signed-off-by: Edwin Kempin <ekempin@google.com> Reviewed-on: https://gerrit-review.googlesource.com/c/plugins/code-owners/+/434337 Reviewed-by: Kamil Musin <kamilm@google.com> Tested-by: Zuul <zuul-63@gerritcodereview-ci.iam.gserviceaccount.com>
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.