forked from kemitix/git-next
refactor: move server config loading out of forgejo module
Delete empty modules left over
This commit is contained in:
parent
0bfa1df875
commit
50a969ede6
9 changed files with 9 additions and 55 deletions
|
@ -1,31 +1,17 @@
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::server::{
|
use crate::server::{config::RepoDetails, gitforge};
|
||||||
config::{ForgeType, RepoDetails},
|
|
||||||
forge, gitforge,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{LoadedConfig, RepoActor};
|
use super::{LoadedConfig, RepoActor};
|
||||||
|
|
||||||
pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
|
pub async fn load(repo_details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
|
||||||
let config = match details.config {
|
let config = match crate::server::config::load::load(&repo_details, &forge).await {
|
||||||
Some(config) => config,
|
|
||||||
None => {
|
|
||||||
let config = match details.forge.forge_type {
|
|
||||||
#[cfg(feature = "forgejo")]
|
|
||||||
ForgeType::ForgeJo => forge::forgejo::config::load(&details, &forge).await,
|
|
||||||
#[cfg(test)]
|
|
||||||
ForgeType::MockForge => forge::mock::config::load(&details, &forge).await,
|
|
||||||
};
|
|
||||||
match config {
|
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(?err, "Failed to load config");
|
error!(?err, "Failed to load config");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
addr.do_send(LoadedConfig(config));
|
addr.do_send(LoadedConfig(config));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
pub mod load;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
|
@ -1 +0,0 @@
|
||||||
pub mod config;
|
|
|
@ -1,14 +0,0 @@
|
||||||
use terrors::OneOf;
|
|
||||||
|
|
||||||
use crate::server::{
|
|
||||||
config::RepoConfig,
|
|
||||||
forge::forgejo::config::RepoConfigValidationErrors,
|
|
||||||
gitforge::{self, ForgeFileError},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn load(
|
|
||||||
_details: &crate::server::config::RepoDetails,
|
|
||||||
_forge: &gitforge::Forge,
|
|
||||||
) -> Result<RepoConfig, OneOf<(ForgeFileError, toml::de::Error, RepoConfigValidationErrors)>> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
pub mod config;
|
|
|
@ -1,7 +0,0 @@
|
||||||
#[cfg(feature = "forgejo")]
|
|
||||||
pub mod forgejo;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub mod mock;
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
|
@ -1,10 +0,0 @@
|
||||||
use kxio::network;
|
|
||||||
|
|
||||||
use crate::server::gitforge;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
const fn test_is_send() {
|
|
||||||
const fn assert_send<T: Send>() {}
|
|
||||||
assert_send::<gitforge::CommitHistories>();
|
|
||||||
assert_send::<network::NetworkError>();
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
mod actors;
|
mod actors;
|
||||||
mod config;
|
mod config;
|
||||||
pub mod forge;
|
|
||||||
pub mod gitforge;
|
pub mod gitforge;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue