1use std::path::PathBuf;
2use std::process::ExitStatus;
3use std::string::FromUtf8Error;
4
5use thiserror::Error;
6use walkdir::Error as WalkdirError;
7
8#[derive(Debug, Error)]
10pub enum GitToolingError {
11 #[error("git command `{command}` failed with status {status}: {stderr}")]
12 GitCommand {
13 command: String,
14 status: ExitStatus,
15 stderr: String,
16 },
17 #[error("git command `{command}` produced non-UTF-8 output")]
18 GitOutputUtf8 {
19 command: String,
20 #[source]
21 source: FromUtf8Error,
22 },
23 #[error("{path:?} is not a git repository")]
24 NotAGitRepository { path: PathBuf },
25 #[error("path {path:?} must be relative to the repository root")]
26 NonRelativePath { path: PathBuf },
27 #[error("path {path:?} escapes the repository root")]
28 PathEscapesRepository { path: PathBuf },
29 #[error("failed to process path inside worktree")]
30 PathPrefix(#[from] std::path::StripPrefixError),
31 #[error(transparent)]
32 Walkdir(#[from] WalkdirError),
33 #[error(transparent)]
34 Io(#[from] std::io::Error),
35}