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

31 lines
896 B
Rust
Raw Normal View History

use actix::prelude::*;
use git_next_git as git;
2024-05-19 16:07:29 +01:00
use tracing::{info, warn};
use crate::{actors::repo::ValidateRepo, gitforge};
use super::AdvanceMainTo;
pub async fn check_next(
next: git::Commit,
addr: Addr<super::RepoActor>,
forge: gitforge::Forge,
message_token: gitforge::MessageToken,
) {
// get the status - pass, fail, pending (all others map to fail, e.g. error)
let status = forge.commit_status(&next).await;
2024-04-12 17:41:09 +01:00
info!(?status, "Checking next branch");
match status {
gitforge::CommitStatus::Pass => {
addr.do_send(AdvanceMainTo(next));
}
gitforge::CommitStatus::Pending => {
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
addr.do_send(ValidateRepo { message_token });
}
gitforge::CommitStatus::Fail => {
warn!("Checks have failed");
}
}
}