1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use crate::{config_struct, config_unit_enum, is_false};
use rustc_hash::FxHashMap;
use schematic::{Config, ConfigEnum};
config_unit_enum!(
/// The VCS being utilized by the repository.
#[derive(ConfigEnum)]
pub enum VcsClient {
#[default]
Git,
}
);
config_unit_enum!(
/// The upstream version control provider, where the repository
/// source code is stored.
#[derive(ConfigEnum)]
pub enum VcsProvider {
Bitbucket,
#[default]
#[serde(rename = "github")]
GitHub,
#[serde(rename = "gitlab")]
GitLab,
Other,
}
);
config_unit_enum!(
/// The format to use for generated VCS hook files.
/// @since 1.29.0
#[derive(ConfigEnum)]
pub enum VcsHookFormat {
Bash,
#[default]
Native,
}
);
config_struct!(
/// Configures the version control system (VCS).
#[derive(Config)]
pub struct VcsConfig {
/// The VCS client being utilized by the repository.
pub client: VcsClient,
/// The default branch / base.
#[setting(default = "master")]
pub default_branch: String,
/// A map of hooks to a list of commands to run when the hook is triggered.
/// @since 1.9.0
#[serde(default, skip_serializing_if = "FxHashMap::is_empty")]
pub hooks: FxHashMap<String, Vec<String>>,
/// The format to use for generated VCS hook files.
/// @since 1.29.0
pub hook_format: VcsHookFormat,
/// The upstream version control provider, where the repository
/// source code is stored.
/// @since 1.8.0
pub provider: VcsProvider,
/// List of remote's in which to compare branches against.
#[setting(default = vec!["origin".into(), "upstream".into()])]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub remote_candidates: Vec<String>,
/// Automatically generate hooks and scripts during a sync operation,
/// based on the `hooks` setting.
/// @since 1.9.0
#[serde(default, skip_serializing_if = "is_false")]
pub sync: bool,
}
);
impl VcsConfig {
pub fn should_invalidate(&self, other: &Self) -> bool {
self.default_branch != other.default_branch
|| self.remote_candidates != other.remote_candidates
}
}