git-next/src/server/actors/repo/status.rs

45 lines
1.2 KiB
Rust

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<super::RepoActor>,
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 {
ForgeType::ForgeJo => {
forge::forgejo::get_commit_status(next.clone(), repo_details, net).await
}
};
info!(?status, "Checking next branch status");
match status {
Status::Pass => {
addr.do_send(AdvanceMainTo(next));
}
Status::Pending => {
info!("Checks are pending");
} // TODO: (#22) wait and try again OR can webhook tell us when it's done, in
// which case we can do nothing here and wait for the webhook to trigger
Status::Fail => {
warn!("Check have failed");
} // TODO: (#21) reset next and wait for dev to be updated and this
// commit removed from the commit history before trying again
}
}
#[derive(Debug)]
pub enum Status {
Pass,
Fail,
Pending,
}