hubcaps_ex/
pull_commits.rs1use serde::Deserialize;
3
4use crate::users::User;
5use crate::{Future, Github, Stream};
6
7pub struct PullCommits {
9 github: Github,
10 owner: String,
11 repo: String,
12 number: u64,
13}
14
15impl PullCommits {
16 #[doc(hidden)]
17 pub fn new<O, R>(github: Github, owner: O, repo: R, number: u64) -> Self
18 where
19 O: Into<String>,
20 R: Into<String>,
21 {
22 PullCommits {
23 github,
24 owner: owner.into(),
25 repo: repo.into(),
26 number,
27 }
28 }
29
30 pub fn list(&self) -> Future<Vec<PullCommit>> {
32 let uri = format!(
33 "/repos/{}/{}/pulls/{}/commits",
34 self.owner, self.repo, self.number
35 );
36 self.github.get::<Vec<PullCommit>>(&uri)
37 }
38
39 pub fn iter(&self) -> Stream<PullCommit> {
41 self.github.get_stream(&format!(
42 "/repos/{}/{}/pulls/{}/commits",
43 self.owner, self.repo, self.number
44 ))
45 }
46}
47
48#[derive(Debug, Deserialize)]
52pub struct PullCommit {
53 pub url: String,
54 pub sha: String,
55 pub html_url: String,
56 pub comments_url: String,
57 pub commit: CommitDetails,
58 pub author: User,
59 pub committer: User,
60 pub parents: Vec<CommitRef>,
61}
62
63#[derive(Debug, Deserialize)]
65pub struct CommitDetails {
66 pub url: String,
67 pub author: UserStamp,
68 pub committer: Option<UserStamp>,
69 pub message: String,
70 pub tree: CommitRef,
71 pub comment_count: u64,
72}
73
74#[derive(Debug, Deserialize)]
76pub struct CommitRef {
77 pub url: String,
78 pub sha: String,
79}
80
81#[derive(Debug, Deserialize)]
83pub struct UserStamp {
84 pub name: String,
85 pub email: String,
86 pub date: String,
87}