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
//! Types related to git

use std::collections::HashMap;

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

use crate::helpers::Class;

/// Describe a git branch
#[derive(Deserialize, Debug)]
pub struct Branch {
    /// SHA1 of the branch
    #[serde(rename = "SHA1")]
    pub sha1: String,
    /// Name of the branch
    pub name: String,
}

/// Revision from git
#[derive(Deserialize, Debug)]
pub struct Revision {
    /// SHA1 of the revision
    #[serde(rename = "SHA1")]
    pub sha1: String,
    /// Branch information
    pub branch: Vec<Branch>,
}

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

/// Information about a build related to a branch
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CommonBranchBuild {
    /// _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!(CommonBranchBuild => BranchBuild);
impl BranchBuild for CommonBranchBuild {}

/// Build from a git branch
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GitBranchBuild {
    /// Revision
    pub revision: Revision,
    /// Build number
    pub build_number: u32,
    /// Build result
    pub build_result: Option<crate::build::BuildStatus>,
    /// Marked revision
    pub marked: Revision,
}
register_class!("hudson.plugins.git.util.Build" => GitBranchBuild);
impl BranchBuild for GitBranchBuild {}

/// HashMap of builds by branch name
#[derive(Deserialize, Debug)]
pub struct BuildsByBranch {
    /// HashMap of builds by branch name
    #[serde(flatten)]
    pub branches: HashMap<String, CommonBranchBuild>,
}