diff --git a/crates/server/src/config/load.rs b/crates/server/src/config/load.rs index 1d63c16c..62693464 100644 --- a/crates/server/src/config/load.rs +++ b/crates/server/src/config/load.rs @@ -8,15 +8,7 @@ use crate::gitforge::{self, ForgeFileError}; pub async fn load( details: &RepoDetails, forge: &gitforge::Forge, -) -> Result< - RepoConfig, - OneOf<( - ForgeFileError, - crate::config::Error, - toml::de::Error, - RepoConfigValidationErrors, - )>, -> { +) -> Result> { let contents = forge .file_contents_get(&details.branch, ".git-next.toml") .await @@ -27,42 +19,33 @@ pub async fn load( } #[derive(Debug)] -pub enum RepoConfigValidationErrors { +pub enum Error { Forge(gitforge::ForgeBranchError), BranchNotFound(BranchName), } -pub async fn validate( - config: RepoConfig, - forge: &gitforge::Forge, -) -> Result { +pub async fn validate(config: RepoConfig, forge: &gitforge::Forge) -> Result { let branches = forge.branches_get_all().await.map_err(|e| { error!(?e, "Failed to list branches"); - RepoConfigValidationErrors::Forge(e) + Error::Forge(e) })?; if !branches .iter() .any(|branch| branch == &config.branches().main()) { - return Err(RepoConfigValidationErrors::BranchNotFound( - config.branches().main(), - )); + return Err(Error::BranchNotFound(config.branches().main())); } if !branches .iter() .any(|branch| branch == &config.branches().next()) { - return Err(RepoConfigValidationErrors::BranchNotFound( - config.branches().next(), - )); + return Err(Error::BranchNotFound(config.branches().next())); } if !branches .iter() .any(|branch| branch == &config.branches().dev()) { - return Err(RepoConfigValidationErrors::BranchNotFound( - config.branches().dev(), - )); + return Err(Error::BranchNotFound(config.branches().dev())); } Ok(config) }