git-next/crates/repo-actor/src/handlers/clone_repo.rs

45 lines
1.6 KiB
Rust
Raw Normal View History

//
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 {
actor::logger(&self.log, "Handler: CloneRepo: start");
tracing::debug!("Handler: CloneRepo: start");
match git::repository::open(&*self.repository_factory, &self.repo_details) {
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() {
actor::do_send(
ctx.address(),
actor::messages::LoadConfigFromRepo,
&self.log,
);
} else {
actor::do_send(
ctx.address(),
actor::messages::RegisterWebhook::new(),
&self.log,
);
}
}
Err(err) => {
actor::logger(&self.log, "open failed");
tracing::debug!("err: {err:?}");
tracing::warn!("Could not open repo: {err}")
}
}
tracing::debug!("Handler: CloneRepo: finish");
}
}