Add in-memory CodeOwnerConfigCache across requests TransientCodeOwnerConfigCache was originally transient to prevent returning stale CodeOwnerConfig entries when getFromCurrentRevision passed revision = null. This change introduces CodeOwnerConfigCache, a thread-safe in-memory cache keyed strictly by (CodeOwnerConfig.Key, ObjectId revision) configured via CacheModule in BackendModule, exposing it to Gerrit's cache metrics (Prometheus) and administrative commands (show-caches, flush-caches). Because entries are keyed by immutable Git commit ObjectIds, entries never become stale, and eviction is governed purely by the configured maximum cache size (LRU). TransientCodeOwnerConfigCache maintains the L1 (request-local) -> L2 (process-wide) cache hierarchy: - L1 hits return in O(1) time without Git ref resolution. - On an L1 miss, branch revision is resolved once and L2 is checked. - On an L2 hit, L1 is populated for fast subsequent lookups, respecting the per-request cache size limit. - On an L2 miss, the config is loaded and cached in both L1 and L2. - Non-existent branches are cached in L1 to prevent repeated disk I/O. Cost/Benefit: - Benefit: Eliminates repeated Git tree walks, distributed blob reads, and OWNERS parsing across the push and submit requirement validation lifecycle, saving an estimated ~500 ms to 1.5+ seconds per patch set upload on large repositories like chromium/src. - Cost: Up to ~10-50 MB JVM heap overhead for 10k cached configs. Change-Id: I1983e074bd896aa2fc1594bb68e0801aa653853b
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.