use std::path::PathBuf;
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Error, Diagnostic)]
#[non_exhaustive]
pub enum RepoError {
#[error("io error at `{path}`: {source}")]
#[diagnostic(code(rtb_vcs::git::io))]
Io {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("could not open repository at `{path}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::open_failed))]
OpenFailed {
path: PathBuf,
cause: String,
},
#[error("could not init repository at `{path}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::init_failed))]
InitFailed {
path: PathBuf,
cause: String,
},
#[error("could not clone `{url}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::clone_failed))]
CloneFailed {
url: String,
cause: String,
},
#[error("could not fetch from `{remote}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::fetch_failed))]
FetchFailed {
remote: String,
cause: String,
},
#[error("could not check out `{revspec}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::checkout_failed))]
CheckoutFailed {
revspec: String,
cause: String,
},
#[error("could not create commit: {cause}")]
#[diagnostic(code(rtb_vcs::git::commit_failed))]
CommitFailed {
cause: String,
},
#[error("could not compute status: {cause}")]
#[diagnostic(code(rtb_vcs::git::status_failed))]
StatusFailed {
cause: String,
},
#[error("could not walk commits: {cause}")]
#[diagnostic(code(rtb_vcs::git::walk_failed))]
WalkFailed {
cause: String,
},
#[error("could not diff trees: {cause}")]
#[diagnostic(code(rtb_vcs::git::diff_failed))]
DiffFailed {
cause: String,
},
#[error("could not push `{refspec}` to `{remote}`: {cause}")]
#[diagnostic(code(rtb_vcs::git::push_failed))]
PushFailed {
remote: String,
refspec: String,
cause: String,
},
#[error("revspec `{revspec}` not found")]
#[diagnostic(code(rtb_vcs::git::revspec_not_found))]
RevspecNotFound {
revspec: String,
},
#[error("working tree is dirty: {} path(s) need attention", paths.len())]
#[diagnostic(code(rtb_vcs::git::dirty_working_tree))]
DirtyWorkingTree {
paths: Vec<PathBuf>,
},
#[error("credential resolution failed: {0}")]
#[diagnostic(code(rtb_vcs::git::auth))]
Auth(
#[from]
#[source]
rtb_credentials::CredentialError,
),
#[error("push is not supported without the `git2-fallback` Cargo feature")]
#[diagnostic(
code(rtb_vcs::git::push_unsupported),
help("enable the `git2-fallback` feature on `rtb-vcs` to opt into libgit2-backed push")
)]
PushUnsupported,
}