Paul Campbell
91870055b0
All checks were successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
Closes kemitix/git-next#56
58 lines
2 KiB
Rust
58 lines
2 KiB
Rust
use crate::server::config::BranchName;
|
|
|
|
#[derive(Debug)]
|
|
pub enum ForgeFileError {
|
|
NotFound(String),
|
|
ParseContent,
|
|
DecodeFromBase64,
|
|
DecodeFromUtf8,
|
|
UnknownEncoding(String),
|
|
NotFile(String),
|
|
Unknown(String),
|
|
}
|
|
impl std::error::Error for ForgeFileError {}
|
|
impl std::fmt::Display for ForgeFileError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::NotFound(file_path) => write!(f, "File not found: {file_path}"),
|
|
Self::NotFile(file_path) => write!(f, "Not a file: {file_path}"),
|
|
Self::DecodeFromBase64 => write!(f, "Unable to decode from base64"),
|
|
Self::DecodeFromUtf8 => write!(f, "Unable to decode from UTF-8"),
|
|
Self::UnknownEncoding(encoding) => write!(f, "Unknown file encoding: {encoding}"),
|
|
Self::ParseContent => write!(f, "Unable to parse file contents"),
|
|
Self::Unknown(status) => write!(f, "Unknown error (status: {status})"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum ForgeBranchError {
|
|
NotFound(BranchName),
|
|
NoneFound,
|
|
}
|
|
impl std::error::Error for ForgeBranchError {}
|
|
impl std::fmt::Display for ForgeBranchError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::NotFound(branch_name) => write!(f, "Branch not found: {branch_name}"),
|
|
Self::NoneFound => write!(f, "Unable to find any branches"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum RepoCloneError {
|
|
InvalidGitDir(std::path::PathBuf),
|
|
Wait(std::io::Error),
|
|
Spawn(std::io::Error),
|
|
}
|
|
impl std::error::Error for RepoCloneError {}
|
|
impl std::fmt::Display for RepoCloneError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::InvalidGitDir(gitdir) => write!(f, "Invalid Git dir: {:?}", gitdir),
|
|
Self::Wait(err) => write!(f, "Waiting for command: {:?}", err),
|
|
Self::Spawn(err) => write!(f, "Spawning comming: {:?}", err),
|
|
}
|
|
}
|
|
}
|