wire/answer/git_status.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! What is uncommitted in one building, and the last checkpoint behind it.
7//!
8//! The rows are [`FileChange`], the same shape `Changes` answers with:
9//! "which files moved and how much" is one question whether the far end
10//! is a checkpoint or the disk, and a second row type would be a second
11//! answer to it.
12
13use kernel::{Address, FileChange};
14use serde::{Deserialize, Serialize};
15
16use super::CommitAnswer;
17
18/// How far a branch has drifted from the upstream it tracks.
19///
20/// Absent as a whole rather than as two zeroes when the branch tracks
21/// nothing: a branch with no upstream is not a branch level with one,
22/// and a page that read `0/0` for both would tell a person their work
23/// is pushed.
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
25#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
26pub struct Drift {
27 pub ahead: u64,
28 pub behind: u64,
29}
30
31/// The working tree of one building, read at the moment of asking.
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
34pub struct GitStatusAnswer {
35 pub building: Address,
36 /// The branch checked out, or absent on a detached head - which is
37 /// a state a person can be in and one a name cannot describe.
38 pub branch: Option<String>,
39 /// Absent when the branch tracks no upstream.
40 pub drift: Option<Drift>,
41 /// Files under this building that differ from the last commit,
42 /// untracked ones included, in path order.
43 pub files: Vec<FileChange>,
44 /// The newest commit this city checkpointed at this building, from the
45 /// history rather than from git, for the reason `Query::Commit`
46 /// gives. Absent when the city has checkpointed nothing here.
47 pub checkpoint: Option<CommitAnswer>,
48}