use actix::prelude::*; use gix::trace::warn; use tracing::info; use crate::server::{ config::{self, ForgeType}, forge, }; use super::AdvanceMainTo; pub async fn check_next( next: forge::Commit, repo_details: config::RepoDetails, addr: Addr, net: kxio::network::Network, ) { // get the status - pass, fail, pending (all others map to fail, e.g. error) let status = match repo_details.forge.forge_type { #[cfg(feature = "forgejo")] ForgeType::ForgeJo => { forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await } #[cfg(test)] ForgeType::MockForge => { forge::mock::get_commit_status(next.clone(), &repo_details, &net).await } }; info!(?status, "Checking next branch"); match status { Status::Pass => { addr.do_send(AdvanceMainTo(next)); } Status::Pending => { // TODO: (#48) reschedule a check after a few seconds } Status::Fail => { warn!("Checks have failed"); } } } #[derive(Debug)] pub enum Status { Pass, Fail, Pending, }