Skip to main content

mantle_git/
types.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
4#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
5pub struct CowCloneResult {
6    pub cloned_count: u32,
7    pub fallback_count: u32,
8    pub elapsed_ms: u64,
9    pub errors: Vec<String>,
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
13#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
14pub enum ArtifactType {
15    Node,
16    NodePnpm,
17    Rust,
18    Python,
19    Swift,
20    Generic,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
24#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
25pub enum HydrationStrategy {
26    CowClone,
27    DelegateToPnpm,
28    /// Reserved for future use. Originally intended for sccache injection into
29    /// Rust `target/` directories, but `CoW` clone handles all artifact types
30    /// (including Rust) effectively. Currently never returned by `resolve_strategy()`.
31    InjectCache,
32    Skip,
33}
34
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
36#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
37pub enum ConfigSource {
38    BuiltIn,
39    Worktreeinclude,
40    Gitignore,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
44#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
45pub enum IncludeSource {
46    Worktreeinclude,
47    GitignoreFallback,
48    None,
49}
50
51#[derive(Debug, Clone, Serialize)]
52#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
53pub struct CloneCandidate {
54    pub source_path: String,
55    pub dest_path: String,
56    pub artifact_type: ArtifactType,
57    pub lockfile_matches: bool,
58    pub size_bytes: u64,
59    pub strategy: HydrationStrategy,
60    pub skip_reason: Option<String>,
61    pub config_source: ConfigSource,
62}
63
64#[derive(Debug, Clone, Serialize)]
65#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
66pub struct FileCandidate {
67    pub relative_path: String,
68    pub absolute_path: String,
69    pub size_bytes: u64,
70}
71
72#[derive(Debug, Clone, Serialize)]
73#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
74pub struct WorktreeIncludeResult {
75    pub clone_candidates: Vec<CloneCandidate>,
76    pub file_candidates: Vec<FileCandidate>,
77    pub source: IncludeSource,
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
81#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
82pub enum EffectiveSource {
83    BuiltIn,
84    Worktreeinclude,
85    Gitignore,
86    GitignoreLifted,
87    Suggestion,
88}
89
90#[derive(Debug, Clone, Serialize)]
91#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
92pub struct EffectiveEntry {
93    pub path: String,
94    pub source: EffectiveSource,
95    pub exists_on_disk: bool,
96    pub size_bytes: u64,
97    pub included: bool,
98}
99
100#[derive(Debug, Clone, Serialize)]
101#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
102pub struct EffectiveWorktreeinclude {
103    pub entries: Vec<EffectiveEntry>,
104    pub config_source: ConfigSource,
105    pub has_worktreeinclude_file: bool,
106    pub suggestions: Vec<String>,
107}
108
109#[derive(Debug, Clone, Serialize)]
110#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
111pub struct GeneratedWorktreeinclude {
112    /// The generated file content, ready to write to `.worktreeinclude`.
113    pub content: String,
114    /// Directory names included from built-in artifact specs.
115    pub builtin_dirs: Vec<String>,
116    /// Directory names included from `.gitignore` parsing.
117    pub gitignore_dirs: Vec<String>,
118    /// Whether a `.worktreeinclude` file already existed (content is still generated but not written).
119    pub already_exists: bool,
120}
121
122#[derive(Debug, Clone, Serialize)]
123#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
124pub struct WorktreeInfo {
125    pub path: String,
126    pub head: String,
127    pub branch: Option<String>,
128    pub is_main: bool,
129}
130
131#[derive(Debug, Clone, Serialize)]
132#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
133pub struct CommitInfo {
134    pub hash: String,
135    pub author_name: String,
136    pub author_email: String,
137    pub committer_name: String,
138    pub committer_email: String,
139    pub author_date: String,
140    pub message: String,
141    pub parent_hashes: Vec<String>,
142}
143
144#[derive(Debug, Clone, Serialize)]
145#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
146pub struct BranchInfo {
147    pub name: String,
148    pub date: String,
149    pub author: String,
150    pub hash: String,
151}
152
153#[derive(Debug, Clone, Serialize)]
154#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
155pub struct StatusSummary {
156    pub file_count: u32,
157    pub output: String,
158}
159
160#[derive(Debug, Clone, Serialize)]
161#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
162pub struct WorktreeStatusInfo {
163    pub is_dirty: bool,
164    pub file_count: u32,
165}
166
167#[derive(Debug, Clone, Serialize)]
168#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
169pub struct RemoteInfo {
170    pub name: String,
171    pub push_url: Option<String>,
172    pub fetch_url: Option<String>,
173}
174
175#[derive(Debug, Clone, Serialize)]
176#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
177pub struct FetchResult {
178    pub updated_refs: Vec<String>,
179}
180
181#[derive(Debug, Clone, Serialize)]
182#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
183pub struct PushResult {
184    pub updated_ref: Option<String>,
185    pub up_to_date: bool,
186}
187
188#[derive(Debug, Clone, Serialize)]
189#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
190pub struct PullResult {
191    pub fetch_updated_refs: Vec<String>,
192    pub merge_type: String,
193    pub new_head: Option<String>,
194}
195
196#[derive(Debug, Clone, Serialize)]
197#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
198pub struct AheadBehindResult {
199    pub ahead: u32,
200    pub behind: u32,
201}
202
203#[derive(Debug, Clone, Serialize)]
204#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
205pub struct CommitTreeRefsInfo {
206    pub tree_hash: String,
207    pub refs: String,
208}
209
210#[derive(Debug, Clone, Serialize)]
211#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
212pub struct BlameLineInfo {
213    pub commit_hash: String,
214    pub author_name: String,
215    pub author_email: String,
216    pub author_date: String,
217    pub line_number: u32,
218    pub num_lines: u32,
219    pub original_line_number: u32,
220}
221
222#[derive(Debug, Clone, Serialize)]
223#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
224pub struct RewriteResult {
225    pub new_head: String,
226    pub backup_ref: String,
227    pub rewritten_count: u32,
228}
229
230#[derive(Debug, Clone, Serialize)]
231#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
232pub struct CommitMetadataInfo {
233    pub author_name: String,
234    pub author_email: String,
235    pub committer_name: String,
236    pub committer_email: String,
237    pub author_date: String,
238    pub committer_date: String,
239}
240
241#[derive(Debug, Clone, Serialize)]
242#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
243pub struct StashEntry {
244    pub index: u32,
245    pub message: String,
246    pub commit_hash: String,
247}
248
249#[derive(Debug, Clone, Serialize)]
250#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
251pub struct TagInfo {
252    pub name: String,
253    pub target_hash: String,
254    pub is_annotated: bool,
255    pub tagger_name: Option<String>,
256    pub tagger_email: Option<String>,
257    pub tagger_date: Option<String>,
258    pub message: Option<String>,
259}
260
261#[derive(Debug, Clone, Serialize)]
262#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
263pub struct ReflogEntry {
264    pub id: String,
265    pub previous_id: String,
266    pub message: String,
267    pub committer: String,
268    pub date: String,
269}
270
271#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
272#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
273pub enum MergeStateKind {
274    None,
275    Merge,
276    Rebase,
277    CherryPick,
278}
279
280#[derive(Debug, Clone, Serialize)]
281#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
282pub struct MergeStateInfo {
283    pub kind: MergeStateKind,
284    pub conflict_count: u32,
285    pub branch: Option<String>,
286}
287
288#[derive(Debug, Clone, Serialize)]
289#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
290pub struct ConflictSides {
291    pub path: String,
292    pub base: Option<String>,
293    pub ours: Option<String>,
294    pub theirs: Option<String>,
295}