From f8375ed1fc58f5f2ee4c0997e91f92f2fae346f6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 15 May 2024 20:46:29 +0100 Subject: [PATCH] refactor(server/config): rename RepoConfigValidationError as Error It is never referenced directly outside of this module. --- crates/server/src/config/load.rs | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/crates/server/src/config/load.rs b/crates/server/src/config/load.rs index 1d63c16..6269346 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) }