1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum GitError {
6 #[error("git operation failed")]
7 Git(#[from] git2::Error),
8
9 #[error("not a git repository: '{path}'")]
10 NotARepository { path: PathBuf },
11
12 #[error("failed to resolve reference '{refspec}'")]
13 RefNotFound { refspec: String },
14
15 #[error("working tree has uncommitted changes")]
16 DirtyWorkingTree,
17
18 #[error("failed to delete file at '{path}'")]
19 FileDelete {
20 path: PathBuf,
21 #[source]
22 source: std::io::Error,
23 },
24
25 #[error("HEAD is detached, not on a branch")]
26 DetachedHead,
27
28 #[error("diff delta has no file path")]
29 MissingDeltaPath,
30
31 #[error("HEAD has no parent commit")]
32 NoParentCommit {
33 #[source]
34 source: git2::Error,
35 },
36}