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 #[serde(skip_serializing_if = "Option::is_none")]
25 pub branch_info: Option<BranchInfo>,
26 #[serde(skip_serializing_if = "Option::is_none")]
28 pub pr_template: Option<String>,
29 #[serde(skip_serializing_if = "Option::is_none")]
31 pub branch_prs: Option<Vec<PullRequest>>,
32}
33
34#[derive(Debug, Serialize, Deserialize)]
36pub struct FieldExplanation {
37 pub text: String,
39 pub fields: Vec<FieldDocumentation>,
41}
42
43#[derive(Debug, Serialize, Deserialize)]
45pub struct FieldDocumentation {
46 pub name: String,
48 pub text: String,
50}
51
52#[derive(Debug, Serialize, Deserialize)]
54pub struct WorkingDirectoryInfo {
55 pub clean: bool,
57 pub untracked_changes: Vec<FileStatusInfo>,
59}
60
61#[derive(Debug, Serialize, Deserialize)]
63pub struct FileStatusInfo {
64 pub status: String,
66 pub file: String,
68}
69
70#[derive(Debug, Serialize, Deserialize)]
72pub struct BranchInfo {
73 pub branch: String,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct PullRequest {
80 pub number: u64,
82 pub title: String,
84 pub state: String,
86 pub url: String,
88 pub body: String,
90}
91
92impl Default for FieldExplanation {
93 fn default() -> Self {
95 Self {
96 text: "Field documentation for the YAML output format. Each entry describes the purpose and content of fields returned by the view command.".to_string(),
97 fields: vec![
98 FieldDocumentation {
99 name: "working_directory.clean".to_string(),
100 text: "Boolean indicating if the working directory has no uncommitted changes".to_string(),
101 },
102 FieldDocumentation {
103 name: "working_directory.untracked_changes".to_string(),
104 text: "Array of files with uncommitted changes, showing git status and file path".to_string(),
105 },
106 FieldDocumentation {
107 name: "remotes".to_string(),
108 text: "Array of git remotes with their URLs and detected main branch names".to_string(),
109 },
110 FieldDocumentation {
111 name: "commits[].hash".to_string(),
112 text: "Full SHA-1 hash of the commit".to_string(),
113 },
114 FieldDocumentation {
115 name: "commits[].author".to_string(),
116 text: "Commit author name and email address".to_string(),
117 },
118 FieldDocumentation {
119 name: "commits[].date".to_string(),
120 text: "Commit date in ISO format with timezone".to_string(),
121 },
122 FieldDocumentation {
123 name: "commits[].original_message".to_string(),
124 text: "The original commit message as written by the author".to_string(),
125 },
126 FieldDocumentation {
127 name: "commits[].in_main_branches".to_string(),
128 text: "Array of remote main branches that contain this commit (empty if not pushed)".to_string(),
129 },
130 FieldDocumentation {
131 name: "commits[].analysis.detected_type".to_string(),
132 text: "Automatically detected conventional commit type (feat, fix, docs, test, chore, etc.)".to_string(),
133 },
134 FieldDocumentation {
135 name: "commits[].analysis.detected_scope".to_string(),
136 text: "Automatically detected scope based on file paths (commands, config, tests, etc.)".to_string(),
137 },
138 FieldDocumentation {
139 name: "commits[].analysis.proposed_message".to_string(),
140 text: "AI-generated conventional commit message based on file changes".to_string(),
141 },
142 FieldDocumentation {
143 name: "commits[].analysis.file_changes.total_files".to_string(),
144 text: "Total number of files modified in this commit".to_string(),
145 },
146 FieldDocumentation {
147 name: "commits[].analysis.file_changes.files_added".to_string(),
148 text: "Number of new files added in this commit".to_string(),
149 },
150 FieldDocumentation {
151 name: "commits[].analysis.file_changes.files_deleted".to_string(),
152 text: "Number of files deleted in this commit".to_string(),
153 },
154 FieldDocumentation {
155 name: "commits[].analysis.file_changes.file_list".to_string(),
156 text: "Array of files changed with their git status (M=modified, A=added, D=deleted)".to_string(),
157 },
158 FieldDocumentation {
159 name: "commits[].analysis.diff_summary".to_string(),
160 text: "Git diff --stat output showing lines changed per file".to_string(),
161 },
162 FieldDocumentation {
163 name: "commits[].analysis.diff_content".to_string(),
164 text: "Full diff content showing line-by-line changes with added, removed, and context lines".to_string(),
165 },
166 FieldDocumentation {
167 name: "branch_info.branch".to_string(),
168 text: "Current branch name (only present in branch commands)".to_string(),
169 },
170 FieldDocumentation {
171 name: "pr_template".to_string(),
172 text: "Pull request template content from .github/pull_request_template.md (only present in branch commands when file exists)".to_string(),
173 },
174 FieldDocumentation {
175 name: "branch_prs".to_string(),
176 text: "Pull requests created from the current branch (only present in branch commands)".to_string(),
177 },
178 FieldDocumentation {
179 name: "branch_prs[].number".to_string(),
180 text: "Pull request number".to_string(),
181 },
182 FieldDocumentation {
183 name: "branch_prs[].title".to_string(),
184 text: "Pull request title".to_string(),
185 },
186 FieldDocumentation {
187 name: "branch_prs[].state".to_string(),
188 text: "Pull request state (open, closed, merged)".to_string(),
189 },
190 FieldDocumentation {
191 name: "branch_prs[].url".to_string(),
192 text: "Pull request URL".to_string(),
193 },
194 FieldDocumentation {
195 name: "branch_prs[].body".to_string(),
196 text: "Pull request description/body content".to_string(),
197 },
198 ],
199 }
200 }
201}