Compare commits
2 commits
263cb6d3f1
...
bd6b0b2d31
Author | SHA1 | Date | |
---|---|---|---|
bd6b0b2d31 | |||
7a4f9a45a6 |
6 changed files with 19 additions and 10 deletions
|
@ -18,22 +18,26 @@ impl Handler<CloneRepo> for RepoActor {
|
||||||
#[instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details))]
|
#[instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details))]
|
||||||
fn handle(&mut self, _msg: CloneRepo, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, _msg: CloneRepo, ctx: &mut Self::Context) -> Self::Result {
|
||||||
logger(self.log.as_ref(), "Handler: CloneRepo: start");
|
logger(self.log.as_ref(), "Handler: CloneRepo: start");
|
||||||
self.update_tui(RepoUpdate::Cloning);
|
self.update_tui(RepoUpdate::Opening);
|
||||||
debug!("Handler: CloneRepo: start");
|
debug!("Handler: CloneRepo: start");
|
||||||
match git::repository::open(&*self.repository_factory, &self.repo_details) {
|
match git::repository::open(&*self.repository_factory, &self.repo_details) {
|
||||||
Ok(repository) => {
|
Ok(repository) => {
|
||||||
logger(self.log.as_ref(), "open okay");
|
logger(self.log.as_ref(), "open okay");
|
||||||
debug!("open okay");
|
debug!("open okay");
|
||||||
|
self.update_tui(RepoUpdate::Opened);
|
||||||
self.open_repository.replace(repository);
|
self.open_repository.replace(repository);
|
||||||
if self.repo_details.repo_config.is_none() {
|
if self.repo_details.repo_config.is_none() {
|
||||||
|
self.update_tui(RepoUpdate::LoadingConfigFromRepo);
|
||||||
do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref());
|
do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref());
|
||||||
} else {
|
} else {
|
||||||
|
self.update_tui(RepoUpdate::RegisteringWebhook);
|
||||||
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
logger(self.log.as_ref(), "open failed");
|
logger(self.log.as_ref(), "open failed");
|
||||||
warn!("Could not open repo: {err:?}");
|
warn!("Could not open repo: {err:?}");
|
||||||
|
self.alert_tui(err.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("Handler: CloneRepo: finish");
|
debug!("Handler: CloneRepo: finish");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
|
|
||||||
use tracing::{debug, Instrument as _};
|
use tracing::{debug, error, Instrument as _};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
repo::{
|
repo::{
|
||||||
|
@ -33,7 +33,7 @@ impl Handler<RegisterWebhook> for RepoActor {
|
||||||
async move {
|
async move {
|
||||||
match forge.register_webhook(&repo_listen_url).await {
|
match forge.register_webhook(&repo_listen_url).await {
|
||||||
Ok(registered_webhook) => {
|
Ok(registered_webhook) => {
|
||||||
debug!(?registered_webhook, "");
|
debug!(?registered_webhook, "webhook registered");
|
||||||
do_send(
|
do_send(
|
||||||
&addr,
|
&addr,
|
||||||
WebhookRegistered::from(registered_webhook),
|
WebhookRegistered::from(registered_webhook),
|
||||||
|
@ -41,6 +41,7 @@ impl Handler<RegisterWebhook> for RepoActor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
error!(?err, "failed to register webhook");
|
||||||
notify_user(
|
notify_user(
|
||||||
notify_user_recipient.as_ref(),
|
notify_user_recipient.as_ref(),
|
||||||
UserNotification::WebhookRegistration {
|
UserNotification::WebhookRegistration {
|
||||||
|
@ -56,6 +57,8 @@ impl Handler<RegisterWebhook> for RepoActor {
|
||||||
.in_current_span()
|
.in_current_span()
|
||||||
.into_actor(self)
|
.into_actor(self)
|
||||||
.wait(ctx);
|
.wait(ctx);
|
||||||
|
} else {
|
||||||
|
self.alert_tui("already have a webhook id - cant register webhook");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub enum RepoUpdate {
|
||||||
AdvancingMain {
|
AdvancingMain {
|
||||||
commit: git::Commit,
|
commit: git::Commit,
|
||||||
},
|
},
|
||||||
Cloning,
|
Opening,
|
||||||
LoadingConfigFromRepo,
|
LoadingConfigFromRepo,
|
||||||
ReceiveCIStatus {
|
ReceiveCIStatus {
|
||||||
status: Status,
|
status: Status,
|
||||||
|
@ -88,6 +88,7 @@ pub enum RepoUpdate {
|
||||||
push: Push,
|
push: Push,
|
||||||
},
|
},
|
||||||
RegisteredWebhook,
|
RegisteredWebhook,
|
||||||
|
Opened,
|
||||||
}
|
}
|
||||||
|
|
||||||
message!(
|
message!(
|
||||||
|
|
|
@ -56,8 +56,11 @@ impl Handler<ServerUpdate> for Tui {
|
||||||
RepoUpdate::AdvancingMain { commit } => {
|
RepoUpdate::AdvancingMain { commit } => {
|
||||||
repo_state.update_message(format!("advancing main to {commit}"));
|
repo_state.update_message(format!("advancing main to {commit}"));
|
||||||
}
|
}
|
||||||
RepoUpdate::Cloning => {
|
RepoUpdate::Opening => {
|
||||||
repo_state.update_message("cloning...");
|
repo_state.update_message("opening...");
|
||||||
|
}
|
||||||
|
RepoUpdate::Opened => {
|
||||||
|
repo_state.update_message("opened");
|
||||||
}
|
}
|
||||||
RepoUpdate::LoadingConfigFromRepo => {
|
RepoUpdate::LoadingConfigFromRepo => {
|
||||||
repo_state.update_message("loading config from repo...");
|
repo_state.update_message("loading config from repo...");
|
||||||
|
|
|
@ -5,11 +5,9 @@ use ratatui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
text::{Line, Text},
|
text::{Line, Text},
|
||||||
widgets::{Paragraph, Widget},
|
widgets::Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::trace_dbg;
|
|
||||||
|
|
||||||
pub struct ConfiguredRepoWidget<'a> {
|
pub struct ConfiguredRepoWidget<'a> {
|
||||||
pub repo_alias: &'a RepoAlias,
|
pub repo_alias: &'a RepoAlias,
|
||||||
pub message: &'a str,
|
pub message: &'a str,
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub async fn register(
|
||||||
"active": true,
|
"active": true,
|
||||||
"events": ["push"],
|
"events": ["push"],
|
||||||
"config": {
|
"config": {
|
||||||
"url": repo_listen_url.as_ref(),
|
"url": repo_listen_url.to_string(),
|
||||||
"content_type": "json",
|
"content_type": "json",
|
||||||
"secret": authorisation.to_string(),
|
"secret": authorisation.to_string(),
|
||||||
"insecure_ssl": "0",
|
"insecure_ssl": "0",
|
||||||
|
|
Loading…
Reference in a new issue