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
88
89
90
91
92
93
94
95
96
97
98
99
use hyper::client::connect::Connect;
use users::User;
use {unfold, Future, Github, Stream};
fn identity<T>(x: T) -> T {
x
}
pub struct PullCommits<C>
where
C: Clone + Connect + 'static,
{
github: Github<C>,
owner: String,
repo: String,
number: u64,
}
impl<C: Clone + Connect + 'static> PullCommits<C> {
#[doc(hidden)]
pub fn new<O, R>(github: Github<C>, owner: O, repo: R, number: u64) -> Self
where
O: Into<String>,
R: Into<String>,
{
PullCommits {
github,
owner: owner.into(),
repo: repo.into(),
number,
}
}
pub fn list(&self) -> Future<Vec<PullCommit>> {
let uri = format!(
"/repos/{}/{}/pulls/{}/commits",
self.owner, self.repo, self.number
);
self.github.get::<Vec<PullCommit>>(&uri)
}
pub fn iter(&self) -> Stream<PullCommit> {
unfold(
self.github.clone(),
self.github.get_pages(&format!(
"/repos/{}/{}/pulls/{}/commits",
self.owner, self.repo, self.number
)),
identity,
)
}
}
#[derive(Debug, Deserialize)]
pub struct PullCommit {
pub url: String,
pub sha: String,
pub html_url: String,
pub comments_url: String,
pub commit: CommitDetails,
pub author: User,
pub committer: User,
pub parents: Vec<CommitRef>,
}
#[derive(Debug, Deserialize)]
pub struct CommitDetails {
pub url: String,
pub author: UserStamp,
pub committer: Option<UserStamp>,
pub message: String,
pub tree: CommitRef,
pub comment_count: u64,
}
#[derive(Debug, Deserialize)]
pub struct CommitRef {
pub url: String,
pub sha: String,
}
#[derive(Debug, Deserialize)]
pub struct UserStamp {
pub name: String,
pub email: String,
pub date: String,
}