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
//! Source Control Management configuration

use serde::{self, Deserialize, Serialize};

use crate::helpers::Class;

mod browser;
pub use self::browser::*;

/// SCM merge options
#[derive(Default, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct MergeOptions {
    /// Merge strategy
    merge_strategy: String,
    /// Fast forward mode
    fast_forward_mode: String,
    /// Merge target
    merge_target: Option<String>,
    /// Remote branch
    remote_branch_name: Option<String>,
}

/// Trait implemented by specialization of SCM
pub trait SCM {}

/// A SCM
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CommonSCM {
    /// _class provided by Jenkins
    #[serde(rename = "_class")]
    pub class: Option<String>,

    #[cfg(not(feature = "extra-fields-visibility"))]
    #[serde(flatten)]
    extra_fields: serde_json::Value,
    #[cfg(feature = "extra-fields-visibility")]
    /// Extra fields not parsed for a common object
    #[serde(flatten)]
    pub extra_fields: serde_json::Value,
}
specialize!(CommonSCM => SCM);
impl SCM for CommonSCM {}

/// No SCM
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct NullSCM {
    /// Browser
    pub browser: Option<CommonBrowser>,
}
register_class!("hudson.scm.NullSCM" =>  NullSCM);
impl SCM for NullSCM {}

/// Git SCM
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GitSCM {
    /// Browser
    pub browser: Option<CommonBrowser>,
    /// Merge options
    pub merge_options: MergeOptions,
}
register_class!("hudson.plugins.git.GitSCM" =>  GitSCM);
impl SCM for GitSCM {}