1use serde::Serialize;
2use std::fmt;
3
4#[derive(Serialize, Debug, Clone)]
7pub struct CommitContext {
8 pub branch: String,
9 pub recent_commits: Vec<RecentCommit>,
10 pub staged_files: Vec<StagedFile>,
11 pub user_name: String,
12 pub user_email: String,
13}
14
15#[derive(Serialize, Debug, Clone)]
16pub struct RecentCommit {
17 pub hash: String,
18 pub message: String,
19 pub author: String,
20 pub timestamp: String,
21}
22
23#[derive(Serialize, Debug, Clone)]
24pub struct StagedFile {
25 pub path: String,
26 pub change_type: ChangeType,
27 pub diff: String,
28 pub content: Option<String>,
29 pub content_excluded: bool,
30}
31
32#[derive(Serialize, Debug, Clone, PartialEq, Eq)]
33pub enum ChangeType {
34 Added,
35 Modified,
36 Deleted,
37}
38
39impl fmt::Display for ChangeType {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Self::Added => write!(f, "Added"),
43 Self::Modified => write!(f, "Modified"),
44 Self::Deleted => write!(f, "Deleted"),
45 }
46 }
47}
48
49impl CommitContext {
50 pub fn new(
51 branch: String,
52 recent_commits: Vec<RecentCommit>,
53 staged_files: Vec<StagedFile>,
54 user_name: String,
55 user_email: String,
56 ) -> Self {
57 Self {
58 branch,
59 recent_commits,
60 staged_files,
61 user_name,
62 user_email,
63 }
64 }
65}