Skip to main content

mesa_dev/models/
commit.rs

1//! Commit models.
2
3use serde::{Deserialize, Serialize};
4
5/// A commit author or committer.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Author {
8    /// Author name.
9    pub name: String,
10    /// Author email.
11    pub email: String,
12    /// Optional date string.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub date: Option<String>,
15}
16
17/// The action to perform on a file in a commit.
18#[derive(Debug, Clone, Serialize)]
19#[serde(rename_all = "lowercase")]
20pub enum CommitFileAction {
21    /// Create or update the file.
22    Upsert,
23    /// Delete the file.
24    Delete,
25}
26
27/// A file change within a commit.
28#[derive(Debug, Clone, Serialize)]
29pub struct CommitFile {
30    /// The action to perform.
31    pub action: CommitFileAction,
32    /// File path.
33    pub path: String,
34    /// Base64-encoded file content (for upsert).
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub content: Option<String>,
37}
38
39/// Request body for creating a commit.
40#[derive(Debug, Clone, Serialize)]
41pub struct CreateCommitRequest {
42    /// Target branch name.
43    pub branch: String,
44    /// Commit message.
45    pub message: String,
46    /// Commit author.
47    pub author: Author,
48    /// Files to include in the commit.
49    pub files: Vec<CommitFile>,
50    /// Optional base SHA for optimistic concurrency.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub base_sha: Option<String>,
53}
54
55/// Summary of a commit in a list response.
56#[derive(Debug, Clone, Deserialize)]
57pub struct CommitSummary {
58    /// Commit SHA.
59    pub sha: String,
60    /// Commit message.
61    pub message: String,
62}
63
64/// Full commit details.
65#[derive(Debug, Clone, Deserialize)]
66pub struct Commit {
67    /// Commit SHA.
68    pub sha: String,
69    /// Commit message.
70    pub message: String,
71    /// Commit author.
72    pub author: Author,
73    /// Commit committer.
74    pub committer: Author,
75}
76
77/// Paginated list of commits.
78#[derive(Debug, Clone, Deserialize)]
79pub struct ListCommitsResponse {
80    /// The commits in this page.
81    pub commits: Vec<CommitSummary>,
82    /// Cursor for the next page, if more results exist.
83    pub next_cursor: Option<String>,
84    /// Whether more results are available.
85    pub has_more: bool,
86}