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
87
|
#![allow(non_camel_case_types)]
use std::collections::{BTreeMap, BTreeSet};
use serde::{Deserialize, Serialize};
pub type DateTime = chrono::DateTime<chrono::Utc>;
#[allow(clippy::upper_case_acronyms)]
pub type HTML = String;
#[allow(clippy::upper_case_acronyms)]
pub type URI = String;
pub const STATE_VERSION: u32 = 1;
#[derive(Default, Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct State {
pub version: u32,
pub owner: String,
pub repo: String,
pub label: String,
pub issues_updated: Option<DateTime>,
pub issues: BTreeMap<String, Issue>,
pub issue_history: Vec<(DateTime, String, IssueAction)>,
pub pull_requests_updated: Option<DateTime>,
pub pull_requests: BTreeMap<String, PullRequest>,
pub pull_history: Vec<(DateTime, String, PullAction)>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Issue {
#[serde(skip)]
pub id: String,
pub title: String,
pub is_open: bool,
pub body: String,
pub last_update: DateTime,
pub url: String,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum IssueAction {
New,
Closed,
NewClosed,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct PullRequest {
#[serde(skip)]
pub id: String,
pub title: String,
pub is_open: bool,
pub is_merged: bool,
pub body: String,
pub last_update: DateTime,
pub url: String,
pub base_ref: String,
pub merge_commit: Option<String>,
// non-github fields
#[serde(default)]
pub landed_in: BTreeSet<String>,
}
impl PullRequest {
pub fn update(&mut self, from: PullRequest) {
*self = PullRequest {
landed_in: std::mem::replace(&mut self.landed_in, BTreeSet::new()),
..from
}
}
}
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum PullAction {
New,
Closed,
NewClosed,
Merged,
NewMerged,
Landed(Vec<String>)
}
|