refactor(server/config): rename RepoConfigValidationError as Error
Some checks failed
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
/ test (push) Successful in 2s
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline failed
Some checks failed
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
/ test (push) Successful in 2s
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline failed
It is never referenced directly outside of this module.
This commit is contained in:
parent
eb7d14bc33
commit
f8375ed1fc
1 changed files with 7 additions and 24 deletions
|
@ -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<RepoConfig, OneOf<(ForgeFileError, crate::config::Error, toml::de::Error, Error)>> {
|
||||
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<RepoConfig, RepoConfigValidationErrors> {
|
||||
pub async fn validate(config: RepoConfig, forge: &gitforge::Forge) -> Result<RepoConfig, Error> {
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue