commit | d4c91f84eab59e7c59d269ca9efdbb617e9544cd | [log] [tgz] |
---|---|---|
author | Edwin Kempin <ekempin@google.com> | Thu Mar 02 18:24:46 2023 +0100 |
committer | Edwin Kempin <ekempin@google.com> | Fri Mar 03 11:07:18 2023 +0100 |
tree | 05d5e773b3ef93776ea0ce0b9dac02abc614ac57 | |
parent | e87f9cc02fa9d9de97d9f6e4288be2f75a07d0b6 [diff] |
Improve error message when trying to specify code owners by username Code owners in OWNERS files need to be specified by email. It's a common mistake by our users to specify usernames instead (e.g. 'foo' instead of 'foo@google.com'). So far code owners that were specifed by username were rejected with a general "invalid line: ..." error and users had trouble spotting what was wrong. With this change we return a better error message now: "code owner ... in ... cannot be resolved (must be an email)" The generic error was thrown from the parser that parses OWNERS files. We relaxed the matching for code owners there, so that code owners that are specified by username do not cause a parsing error. These code owners are not resolvable and hence parsing them is OK. In CodeOwnerConfigValidator we add a special check for code owners that are usernames and reject them with the better error message. Quite some tests check the behavior with non-parseable OWNERS files. So far to trigger a parsing error these tests created an OWNERS file with a single line being "INVALID". A line in an OWNERS file is invalid if it doesn't match a supported rule with defined keywords and if it cannot be parsed as a code owner. The string "INVALID" doesn't match any keyword rule. So far it couldn't be parsed as a code owner since it was not a valid email, but the parsing logic allows usernames for code owners now. Usernames are just strings that do not contain special characters, so "INVALID" can be parsed as a username now and doesn't cause a parsing error. To trigger a parsing error with the new parsing logic the tests create an OWNERS file with a single line being "@INVALID" now. This string is neither a valid email nor a valid username (as it contains a special character), hence it's causing a parsing error. Bug: Google b/271386354 Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I04efc5028a629e017614cc8c1963f586ec4b5d5b
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
.