Skip to main content

mesa_dev/models/
diff.rs

1//! Diff models.
2
3use serde::Deserialize;
4
5/// Summary statistics for a diff.
6#[derive(Debug, Clone, Deserialize)]
7pub struct DiffStats {
8    /// Number of files changed.
9    pub files: u64,
10    /// Number of lines added.
11    pub additions: u64,
12    /// Number of lines deleted.
13    pub deletions: u64,
14    /// Total number of changes.
15    pub changes: u64,
16}
17
18/// A single file within a diff.
19#[derive(Debug, Clone, Deserialize)]
20pub struct DiffFile {
21    /// File path.
22    pub path: String,
23    /// Change status (e.g. `"added"`, `"modified"`, `"deleted"`).
24    pub status: String,
25    /// Previous path if the file was renamed.
26    pub old_path: Option<String>,
27    /// Size in bytes.
28    pub bytes: Option<u64>,
29    /// Whether the file ends without a newline.
30    pub is_eof: Option<bool>,
31    /// Raw diff output for this file.
32    pub raw: Option<String>,
33}
34
35/// A diff between two refs.
36#[derive(Debug, Clone, Deserialize)]
37pub struct Diff {
38    /// Base ref.
39    pub base: String,
40    /// Head ref.
41    pub head: String,
42    /// Diff statistics.
43    pub stats: DiffStats,
44    /// Files changed.
45    pub files: Vec<DiffFile>,
46    /// Files filtered out (returned without raw diff content).
47    pub filtered_files: Vec<DiffFile>,
48}