moon_config/workspace/codeowners_config.rs
1use crate::{config_struct, config_unit_enum, is_false};
2use indexmap::IndexMap;
3use schematic::{Config, ConfigEnum};
4
5config_unit_enum!(
6 /// How to order ownership rules within the generated file.
7 #[derive(ConfigEnum)]
8 pub enum CodeownersOrderBy {
9 /// By file source path.
10 #[default]
11 FileSource,
12 /// By project identifier.
13 ProjectId,
14 }
15);
16
17config_struct!(
18 /// Configures code ownership rules for generating a `CODEOWNERS` file.
19 #[derive(Config)]
20 pub struct CodeownersConfig {
21 /// A map of global file paths and glob patterns to a list of owners.
22 /// Can be relative from the workspace root, or a wildcard match for any depth.
23 #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
24 pub global_paths: IndexMap<String, Vec<String>>,
25
26 /// How to order ownership rules within the generated file.
27 pub order_by: CodeownersOrderBy,
28
29 /// Bitbucket and GitLab only. The number of approvals required for the
30 /// request to be satisfied. This will be applied to all paths.
31 /// @since 1.28.0
32 #[serde(default, skip_serializing_if = "Option::is_none")]
33 pub required_approvals: Option<u8>,
34
35 /// Automatically generate a `CODEOWNERS` file during a sync operation,
36 /// after aggregating all ownership rules from each project in the workspace.
37 #[serde(default, skip_serializing_if = "is_false")]
38 pub sync: bool,
39 }
40);