forked from kemitix/git-next
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
//
|
|
use crate as actor;
|
|
use actix::prelude::*;
|
|
|
|
impl Handler<actor::messages::AdvanceNext> for actor::RepoActor {
|
|
type Result = ();
|
|
|
|
fn handle(
|
|
&mut self,
|
|
msg: actor::messages::AdvanceNext,
|
|
ctx: &mut Self::Context,
|
|
) -> Self::Result {
|
|
let Some(repo_config) = &self.repo_details.repo_config else {
|
|
return;
|
|
};
|
|
let Some(open_repository) = &self.open_repository else {
|
|
return;
|
|
};
|
|
let (next_commit, dev_commit_history) = msg.unwrap();
|
|
let repo_details = self.repo_details.clone();
|
|
let repo_config = repo_config.clone();
|
|
let addr = ctx.address();
|
|
|
|
match actor::branch::advance_next(
|
|
&next_commit,
|
|
&dev_commit_history,
|
|
repo_details,
|
|
repo_config,
|
|
&**open_repository,
|
|
self.message_token,
|
|
) {
|
|
Ok(message_token) => {
|
|
// pause to allow any CI checks to be started
|
|
std::thread::sleep(self.sleep_duration);
|
|
actor::do_send(
|
|
addr,
|
|
actor::messages::ValidateRepo::new(message_token),
|
|
&self.log,
|
|
);
|
|
}
|
|
Err(err) => tracing::warn!("advance next: {err}"),
|
|
}
|
|
}
|
|
}
|