//! Git repository entity (domain state image). //! //! This is the *entity* describing the derived git state of a project. The //! git **port** (operations) lives in [`crate::ports`]. use serde::{Deserialize, Serialize}; use crate::ids::ProjectId; use crate::project::ProjectPath; /// Derived git state for a project, refreshed via the git port. /// /// Invariant (operational, not enforced here): `root` contains — or will /// contain after `init` — a `.git` directory. This is verified by the /// infrastructure adapter, not by the pure domain. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct GitRepository { /// Owning project. pub project_id: ProjectId, /// Repository root. pub root: ProjectPath, /// Current branch name, if the repo is on a branch. pub current_branch: Option, /// Whether the working tree has uncommitted changes. pub is_dirty: bool, } impl GitRepository { /// Builds a git-state snapshot. #[must_use] pub fn new( project_id: ProjectId, root: ProjectPath, current_branch: Option, is_dirty: bool, ) -> Self { Self { project_id, root, current_branch, is_dirty, } } }