From 17b1629cdf841102be1b9881024d2c749c8169db Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 23 May 2024 17:53:36 +0100 Subject: [PATCH] refactor(repo_actor): merge config and load modules --- crates/repo-actor/src/config.rs | 25 ------------------------- crates/repo-actor/src/lib.rs | 4 ++-- crates/repo-actor/src/load.rs | 24 ++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 29 deletions(-) delete mode 100644 crates/repo-actor/src/config.rs diff --git a/crates/repo-actor/src/config.rs b/crates/repo-actor/src/config.rs deleted file mode 100644 index f09fef20..00000000 --- a/crates/repo-actor/src/config.rs +++ /dev/null @@ -1,25 +0,0 @@ -use actix::prelude::*; - -use git_next_forge as forge; -use git_next_git as git; - -use tracing::{error, info}; - -use crate::load; - -use super::{LoadedConfig, RepoActor}; - -/// Loads the [RepoConfig] from the `.git-next.toml` file in the repository -#[tracing::instrument(skip_all, fields(branch = %repo_details.branch))] -pub async fn load(repo_details: git::RepoDetails, addr: Addr, forge: forge::Forge) { - info!("Loading .git-next.toml from repo"); - let repo_config = match load::load(&repo_details, &forge).await { - Ok(repo_config) => repo_config, - Err(err) => { - error!(?err, "Failed to load config"); - return; - } - }; - info!("Loaded .git-next.toml from repo"); - addr.do_send(LoadedConfig(repo_config)); -} diff --git a/crates/repo-actor/src/lib.rs b/crates/repo-actor/src/lib.rs index ab6c755f..4e8577a0 100644 --- a/crates/repo-actor/src/lib.rs +++ b/crates/repo-actor/src/lib.rs @@ -1,5 +1,4 @@ mod branch; -pub mod config; mod load; pub mod status; pub mod webhook; @@ -11,6 +10,7 @@ use std::time::Duration; use actix::prelude::*; +use crate as repo_actor; use git_next_forge as forge; use git_next_git as git; @@ -120,7 +120,7 @@ impl Handler for RepoActor { let details = self.details.clone(); let addr = ctx.address(); let forge = self.forge.clone(); - config::load(details, addr, forge) + repo_actor::load::load_file(details, addr, forge) .in_current_span() .into_actor(self) .wait(ctx); diff --git a/crates/repo-actor/src/load.rs b/crates/repo-actor/src/load.rs index 335f7a9a..c7d1e3bb 100644 --- a/crates/repo-actor/src/load.rs +++ b/crates/repo-actor/src/load.rs @@ -1,10 +1,30 @@ +// +use actix::prelude::*; + +use tracing::{error, info}; + use git_next_config as config; use git_next_forge as forge; use git_next_git as git; -use tracing::error; +use super::{LoadedConfig, RepoActor}; -pub async fn load( +/// Loads the [RepoConfig] from the `.git-next.toml` file in the repository +#[tracing::instrument(skip_all, fields(branch = %repo_details.branch))] +pub async fn load_file(repo_details: git::RepoDetails, addr: Addr, forge: forge::Forge) { + info!("Loading .git-next.toml from repo"); + let repo_config = match load(&repo_details, &forge).await { + Ok(repo_config) => repo_config, + Err(err) => { + error!(?err, "Failed to load config"); + return; + } + }; + info!("Loaded .git-next.toml from repo"); + addr.do_send(LoadedConfig(repo_config)); +} + +async fn load( details: &git::RepoDetails, forge: &forge::Forge, ) -> Result {