use clankerdiff_core::{DiffError, RepoPathError};
use std::{io, path::PathBuf};
#[derive(Debug, thiserror::Error)]
pub enum GitError {
#[error("path is not inside a Git worktree")]
NotRepository,
#[error("repository root is not valid UTF-8")]
UnsupportedRepositoryPath,
#[error("invalid repository path: {0}")]
InvalidPath(#[from] RepoPathError),
#[error("repository path escapes the worktree: {path}")]
PathEscapesRepository {
path: String,
},
#[error("repository path is not a file: {path}")]
NotAFile {
path: String,
},
#[error("commit message must not be empty")]
EmptyCommitMessage,
#[error("could not execute git operation `{operation}`: {source}")]
Spawn {
operation: &'static str,
#[source]
source: io::Error,
},
#[error("git operation `{operation}` failed with status {status:?}")]
CommandFailed {
operation: &'static str,
status: Option<i32>,
stderr: String,
},
#[error("filesystem operation failed for {path}")]
Io {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("source version is too large ({bytes} bytes)")]
SourceTooLarge { bytes: u64 },
#[error("repository changed while capturing the snapshot")]
UnstableSnapshot,
#[error("could not normalize Git snapshot: {0}")]
Diff(#[from] DiffError),
}