Skip to main content

loom_core/git/
error.rs

1use std::path::PathBuf;
2
3/// Typed errors for git operations, enabling testable error matching.
4/// Keep `anyhow` in the CLI layer; use `GitError` in loom-core for structured handling.
5#[derive(thiserror::Error, Debug)]
6pub enum GitError {
7    #[error("git is not installed or not in PATH")]
8    NotInstalled,
9
10    #[error("git version {found} is below minimum required {required}")]
11    VersionTooOld { found: String, required: String },
12
13    #[error("not a git repository: {}", path.display())]
14    NotARepo { path: PathBuf },
15
16    #[error("branch '{branch}' is already checked out at another worktree")]
17    BranchConflict { branch: String },
18
19    #[error("repository has uncommitted changes")]
20    DirtyWorktree,
21
22    #[error("git command failed: {command}\n{stderr}")]
23    CommandFailed { command: String, stderr: String },
24
25    #[error(transparent)]
26    Io(#[from] std::io::Error),
27}