1use crate::git::{CommitInfo, RemoteInfo};
4use serde::{Deserialize, Serialize};
5
6pub mod amendments;
7pub mod yaml;
8
9pub use amendments::*;
10pub use yaml::*;
11
12#[derive(Debug, Serialize, Deserialize)]
14pub struct RepositoryView {
15 pub explanation: FieldExplanation,
17 pub working_directory: WorkingDirectoryInfo,
19 pub remotes: Vec<RemoteInfo>,
21 pub commits: Vec<CommitInfo>,
23}
24
25#[derive(Debug, Serialize, Deserialize)]
27pub struct FieldExplanation {
28 pub text: String,
30 pub fields: Vec<FieldDocumentation>,
32}
33
34#[derive(Debug, Serialize, Deserialize)]
36pub struct FieldDocumentation {
37 pub name: String,
39 pub text: String,
41}
42
43#[derive(Debug, Serialize, Deserialize)]
45pub struct WorkingDirectoryInfo {
46 pub clean: bool,
48 pub untracked_changes: Vec<FileStatusInfo>,
50}
51
52#[derive(Debug, Serialize, Deserialize)]
54pub struct FileStatusInfo {
55 pub status: String,
57 pub file: String,
59}
60
61impl Default for FieldExplanation {
62 fn default() -> Self {
64 Self {
65 text: "Field documentation for the YAML output format. Each entry describes the purpose and content of fields returned by the view command.".to_string(),
66 fields: vec![
67 FieldDocumentation {
68 name: "working_directory.clean".to_string(),
69 text: "Boolean indicating if the working directory has no uncommitted changes".to_string(),
70 },
71 FieldDocumentation {
72 name: "working_directory.untracked_changes".to_string(),
73 text: "Array of files with uncommitted changes, showing git status and file path".to_string(),
74 },
75 FieldDocumentation {
76 name: "remotes".to_string(),
77 text: "Array of git remotes with their URLs and detected main branch names".to_string(),
78 },
79 FieldDocumentation {
80 name: "commits[].hash".to_string(),
81 text: "Full SHA-1 hash of the commit".to_string(),
82 },
83 FieldDocumentation {
84 name: "commits[].author".to_string(),
85 text: "Commit author name and email address".to_string(),
86 },
87 FieldDocumentation {
88 name: "commits[].date".to_string(),
89 text: "Commit date in ISO format with timezone".to_string(),
90 },
91 FieldDocumentation {
92 name: "commits[].original_message".to_string(),
93 text: "The original commit message as written by the author".to_string(),
94 },
95 FieldDocumentation {
96 name: "commits[].in_main_branches".to_string(),
97 text: "Array of remote main branches that contain this commit (empty if not pushed)".to_string(),
98 },
99 FieldDocumentation {
100 name: "commits[].analysis.detected_type".to_string(),
101 text: "Automatically detected conventional commit type (feat, fix, docs, test, chore, etc.)".to_string(),
102 },
103 FieldDocumentation {
104 name: "commits[].analysis.detected_scope".to_string(),
105 text: "Automatically detected scope based on file paths (commands, config, tests, etc.)".to_string(),
106 },
107 FieldDocumentation {
108 name: "commits[].analysis.proposed_message".to_string(),
109 text: "AI-generated conventional commit message based on file changes".to_string(),
110 },
111 FieldDocumentation {
112 name: "commits[].analysis.file_changes.total_files".to_string(),
113 text: "Total number of files modified in this commit".to_string(),
114 },
115 FieldDocumentation {
116 name: "commits[].analysis.file_changes.files_added".to_string(),
117 text: "Number of new files added in this commit".to_string(),
118 },
119 FieldDocumentation {
120 name: "commits[].analysis.file_changes.files_deleted".to_string(),
121 text: "Number of files deleted in this commit".to_string(),
122 },
123 FieldDocumentation {
124 name: "commits[].analysis.file_changes.file_list".to_string(),
125 text: "Array of files changed with their git status (M=modified, A=added, D=deleted)".to_string(),
126 },
127 FieldDocumentation {
128 name: "commits[].analysis.diff_summary".to_string(),
129 text: "Git diff --stat output showing lines changed per file".to_string(),
130 },
131 ],
132 }
133 }
134}