Notes on customizing your code review policy Notes on customizing your code review policy
To modify an existing code review policy or create your own policy, you need to update the /opt/collabnet/gerrit/etc/gerritforge.mappings file. This requires file system access to the Git integration server.
As long as you are still experimenting with the settings, we recommend that you create a new code review policy rather than modify an existing one. If you delete the gerritforge.mappings file from the file system, it will be automatically recreated with default settings after Gerrit is restarted.
gerritforge.mappings is a Java property file with the format [<name of Git Repo Category>.]<TeamForge SCM permission cluster>.<number of entry>=<Gerrit Access Right Category Code>,(<Lower Bound>,<Upper Bound>[,<ref spec>].
- Git Repo Category is the term internally used to describe a code review policy.
- If no ref spec is specified, the default value refs/* will be assumed.
- If a TeamForge project role has multiple permission clusters, only the most powerful one (scm_admin > scm_delete > scm_commit > scm_view > none) mentioned in the mapping rules file for the corresponding repository category will be considered. If none of the permission clusters of a TeamForge project role are mentioned in the mapping rules file,"none" will assumed. If "none" is not mentioned in the mapping rules, no access rights will be assumed.
- If a Gerrit access right category code is mentioned for a repository category, all previously existing access rights of that access right category will be replaced as long as the [<name of Git Repo Category>.]keep_rights_added_in_gerrit property is set to "false". If this property is set to "true", existing rights will be kept. The [<name of Git Repo Category>.]keep_rights_added_in_gerrit property also determines whether access rights of Gerrit categories not explicitly mentioned for the repository category will be deleted or kept.
Whenever a decision about an access right mapping has to be made for a TeamForge Git repository (which corresponds to a Gerrit project), the repository description is parsed for a string matching the pattern "[RepoCategory:<name of repo category>]". If no occurrence is found, default mapping rules (properties without a repository category) will be used; otherwise, the properties starting with <name of repo category> of the first match will be used. If the repository category is not found, a warning will be issued in the logs and the access rights currently defined will be preserved.
The default code review policies can be expressed as follows:
- default category: [RepoCategory:default] or no mention in the repository description
- mandatory review: [RepoCategory:mandatory_review]
- optional review: [RepoCategory:optional_review]
- custom: [RepoCategory:custom]