octocrab/models/
commits.rs

1use crate::models;
2
3use super::{reactions::ReactionContent, *};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6#[non_exhaustive]
7pub struct Comment {
8    // TODO check actuality comparing with github json schema and pulls::ReviewComment
9    pub html_url: Url,
10    pub url: Url,
11    pub id: CommentId,
12    pub node_id: String,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub body: Option<String>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub path: Option<String>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub position: Option<u64>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub line: Option<u64>,
21    pub commit_id: String,
22    pub user: Author,
23    pub created_at: chrono::DateTime<chrono::Utc>,
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub updated_at: Option<chrono::DateTime<chrono::Utc>>,
26    pub author_association: AuthorAssociation,
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub reactions: Option<CommentReactions>,
29}
30
31/// Reactions summary of a comment
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
33#[serde(rename_all = "snake_case")]
34#[non_exhaustive]
35pub struct CommentReactions {
36    pub url: Url,
37    pub total_count: u64,
38    #[serde(flatten)]
39    pub reactions: Option<HashMap<ReactionContent, u64>>,
40}
41
42/// Commit Comparison
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct CommitComparison {
45    pub ahead_by: i64,
46    /// Commit
47    pub base_commit: Commit,
48    pub behind_by: i64,
49    pub commits: Vec<Commit>,
50    pub diff_url: String,
51    pub files: Option<Vec<repos::DiffEntry>>,
52    pub html_url: String,
53    /// Commit
54    pub merge_base_commit: Commit,
55    pub patch_url: String,
56    pub permalink_url: String,
57    pub status: GithubCommitStatus,
58    pub total_commits: i64,
59    pub url: String,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct CommitElement {
64    pub author: Option<GitUser>,
65    pub comment_count: i64,
66    pub committer: Option<GitUser>,
67    pub message: String,
68    pub tree: Tree,
69    pub url: String,
70    pub verification: Option<Verification>,
71}
72
73/// Metaproperties for Git author/committer information.
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct GitUser {
76    pub date: Option<String>,
77    pub email: Option<String>,
78    pub name: Option<String>,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct Tree {
83    pub sha: String,
84    pub url: String,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct Verification {
89    pub payload: Option<String>,
90    pub reason: String,
91    pub signature: Option<String>,
92    pub verified: bool,
93}
94
95#[deprecated(note = "use repos::DiffEntryStatus instead")]
96pub type FileStatus = repos::DiffEntryStatus;
97
98/// Commit
99#[deprecated(note = "use repos::DiffEntry instead")]
100pub type CommitFile = repos::DiffEntry;
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct CommitParent {
104    pub html_url: Option<String>,
105    pub sha: String,
106    pub url: String,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct CommitStats {
111    pub additions: Option<i64>,
112    pub deletions: Option<i64>,
113    pub total: Option<i64>,
114}
115
116/// Commit
117#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct Commit {
119    pub author: Option<Author>,
120    pub comments_url: String,
121    pub commit: CommitElement,
122    pub committer: Option<Author>,
123    pub files: Option<Vec<repos::DiffEntry>>,
124    pub html_url: String,
125    pub node_id: String,
126    pub parents: Vec<CommitParent>,
127    pub sha: String,
128    pub stats: Option<CommitStats>,
129    pub url: String,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(rename_all = "snake_case")]
134pub enum GithubCommitStatus {
135    Ahead,
136    Behind,
137    Diverged,
138    Identical,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
142pub struct GitCommitObject {
143    pub sha: String,
144    pub node_id: String,
145    pub url: String,
146    pub author: models::repos::CommitAuthor,
147    pub committer: repos::CommitAuthor,
148    pub message: String,
149    pub tree: models::repos::CommitObject,
150    pub parents: Vec<models::repos::Commit>,
151    pub verification: models::repos::Verification,
152    pub html_url: String,
153}