2024-06-19 07:03:08 +01:00
|
|
|
//
|
|
|
|
use actix::prelude::*;
|
|
|
|
|
|
|
|
use crate as actor;
|
|
|
|
use git_next_git as git;
|
|
|
|
|
|
|
|
impl Handler<actor::messages::CloneRepo> for actor::RepoActor {
|
|
|
|
type Result = ();
|
|
|
|
#[tracing::instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details /*, gitdir = %self.repo_details.gitdir */))]
|
|
|
|
fn handle(
|
|
|
|
&mut self,
|
|
|
|
_msg: actor::messages::CloneRepo,
|
|
|
|
ctx: &mut Self::Context,
|
|
|
|
) -> Self::Result {
|
2024-06-30 07:41:13 +01:00
|
|
|
actor::logger(&self.log, "Handler: CloneRepo: start");
|
2024-06-19 07:03:08 +01:00
|
|
|
tracing::debug!("Handler: CloneRepo: start");
|
2024-07-06 19:55:39 +01:00
|
|
|
match git::repository::open(&*self.repository_factory, &self.repo_details) {
|
2024-06-19 07:03:08 +01:00
|
|
|
Ok(repository) => {
|
|
|
|
actor::logger(&self.log, "open okay");
|
|
|
|
tracing::debug!("open okay");
|
|
|
|
self.open_repository.replace(repository);
|
|
|
|
if self.repo_details.repo_config.is_none() {
|
2024-06-30 07:41:13 +01:00
|
|
|
actor::do_send(
|
|
|
|
ctx.address(),
|
|
|
|
actor::messages::LoadConfigFromRepo,
|
|
|
|
&self.log,
|
|
|
|
);
|
2024-06-19 07:03:08 +01:00
|
|
|
} else {
|
2024-06-30 08:09:10 +01:00
|
|
|
actor::do_send(
|
|
|
|
ctx.address(),
|
|
|
|
actor::messages::RegisterWebhook::new(),
|
|
|
|
&self.log,
|
|
|
|
);
|
2024-06-19 07:03:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(err) => {
|
|
|
|
actor::logger(&self.log, "open failed");
|
|
|
|
tracing::debug!("err: {err:?}");
|
|
|
|
tracing::warn!("Could not open repo: {err}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tracing::debug!("Handler: CloneRepo: finish");
|
|
|
|
}
|
|
|
|
}
|