Files
gitks/error.rs
T
zhenyi dcb0fb74c5 feat(core): implement Git repository operations with gRPC services
- Add advertise_refs functionality for Git protocol communication
- Implement archive service with TAR/ZIP format support and streaming
- Create blame service for Git file annotation with line tracking
- Add branch management including create, delete, rename and compare operations
- Implement merge checking with conflict detection and fast-forward handling
- Add cherry-pick functionality for applying commits between branches
- Integrate gix library for Git repository operations and object handling
- Add comprehensive test suite covering all Git operations
- Implement proper error handling and repository validation
- Add pagination support for large result sets
- Create protobuf definitions for all Git operations and data structures
- Add build system for gRPC code generation and dependency management
2026-06-04 13:05:38 +08:00

79 lines
2.5 KiB
Rust

pub type GitResult<T> = Result<T, GitError>;
#[derive(Debug, thiserror::Error)]
pub enum GitError {
#[error("repository is not bare")]
NotBareRepository,
#[error("git command failed with status {status_code:?}: {stderr}")]
CommandFailed {
status_code: Option<i32>,
stderr: String,
},
#[error("unsafe git command rejected: {0}")]
UnsafeCommand(String),
#[error("object not found: {0}")]
ObjectNotFound(String),
#[error("reference not found: {0}")]
RefNotFound(String),
#[error("parse error: {0}")]
ParseError(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("gix error: {0}")]
Gix(String),
#[error("repository not found")]
RepoNotFound,
#[error("internal error: {0}")]
Internal(String),
#[error("not found: {0}")]
NotFound(String),
#[error("invalid oid: {0}")]
InvalidOid(String),
#[error("locked: {0}")]
Locked(String),
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("authentication failed: {0}")]
AuthFailed(String),
#[error("payload too large: {0}")]
PayloadTooLarge(String),
#[error("invalid argument: {0}")]
InvalidArgument(String),
}
macro_rules! impl_gix_error {
($err_type:path) => {
impl From<$err_type> for GitError {
fn from(e: $err_type) -> Self {
GitError::Gix(e.to_string())
}
}
};
}
impl_gix_error!(gix::object::find::existing::Error);
impl_gix_error!(gix::object::find::existing::with_conversion::Error);
impl_gix_error!(gix::object::find::Error);
impl_gix_error!(gix::reference::iter::Error);
impl_gix_error!(gix::reference::iter::init::Error);
impl_gix_error!(gix::reference::find::existing::Error);
impl_gix_error!(gix::reference::find::Error);
impl_gix_error!(gix::reference::head_id::Error);
impl_gix_error!(gix::repository::merge_bases_many::Error);
impl_gix_error!(gix::reference::peel::Error);
impl_gix_error!(gix::repository::blame_file::Error);
impl_gix_error!(gix::blame::Error);
impl_gix_error!(gix::revision::walk::Error);
impl_gix_error!(gix::revision::walk::iter::Error);
impl_gix_error!(gix::revision::spec::parse::single::Error);
impl_gix_error!(gix::open::Error);
impl_gix_error!(gix::objs::decode::Error);
impl_gix_error!(gix::date::Error);
impl_gix_error!(gix::repository::diff_tree_to_tree::Error);
impl From<Box<dyn std::error::Error + Send + Sync>> for GitError {
fn from(e: Box<dyn std::error::Error + Send + Sync>) -> Self {
GitError::Gix(e.to_string())
}
}