From 3735afb2f80d478573e8234fbc2507bec051ec7d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 12 Apr 2024 09:55:50 +0100 Subject: [PATCH] fix: don't reload config when updating next branch The StartRepo handler loads the config before then sending the ValidateRepo message. However, we already have the config, so reloading it isn't needed. Added todo markers on sleep and dispatching of ValidateRepo where it is used as a stop-gap until we have working webhook integration. Add todo markers for checking valid commit messages before advancing next branch. --- src/server/actors/repo/branch.rs | 11 ++++++++--- src/server/actors/repo/status.rs | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/server/actors/repo/branch.rs b/src/server/actors/repo/branch.rs index b54a00d..dc77fab 100644 --- a/src/server/actors/repo/branch.rs +++ b/src/server/actors/repo/branch.rs @@ -6,12 +6,12 @@ use kxio::network; use tracing::{error, info, warn}; use crate::server::{ - actors::repo::branch, + actors::repo::{branch, ValidateRepo}, config::{self, BranchName}, forge, }; -use super::{RepoActor, StartMonitoring, StartRepo}; +use super::{RepoActor, StartMonitoring}; #[tracing::instrument(fields(forge_name = %repo_details.forge.name, repo_name = %repo_details.name), skip_all)] pub async fn validate_positions( @@ -52,6 +52,8 @@ pub async fn validate_positions( ) .is_ok() { + // TODO : (#18) sleep and restart while we don't have webhooks + tokio::time::sleep(std::time::Duration::from_secs(10)).await; addr.do_send(super::ValidateRepo) } return; @@ -121,6 +123,8 @@ pub async fn advance_next( warn!("No commits to advance next to"); return; }; + // TODO: (#33) get commit message for 'commit' + // TODO: (#33) verify commit message is valid match reset( &repo_config.branches().next(), commit, @@ -129,8 +133,9 @@ pub async fn advance_next( ) { Ok(_) => { info!("Success"); + // TODO : (#18) sleep and restart while we don't have webhooks tokio::time::sleep(std::time::Duration::from_secs(10)).await; - addr.do_send(StartRepo); + addr.do_send(ValidateRepo); } Err(err) => { warn!(?err, "Failed") diff --git a/src/server/actors/repo/status.rs b/src/server/actors/repo/status.rs index 11b04f4..851e415 100644 --- a/src/server/actors/repo/status.rs +++ b/src/server/actors/repo/status.rs @@ -34,6 +34,7 @@ pub async fn check_next( warn!("Checks have failed"); } } + // TODO : (#18) sleep and restart while we don't have webhooks tokio::time::sleep(std::time::Duration::from_secs(10)).await; addr.do_send(ValidateRepo); }