forked from kemitix/git-next
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use actix::prelude::*;
|
|
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 => (), // 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 => (), // 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 {
|
|
#[allow(dead_code)] // TODO: (#13) remove this when we have results from the forge
|
|
Pass,
|
|
#[allow(dead_code)] // TODO: (#13) remove this when we have results from the forge
|
|
Fail,
|
|
Pending,
|
|
}
|