WIP: cleanup pedantic clippy
This commit is contained in:
parent
281c07c849
commit
d70e1fd8e5
31 changed files with 83 additions and 77 deletions
10
Cargo.toml
10
Cargo.toml
|
@ -15,11 +15,11 @@ documentation = "https://git.kemitix.net/kemitix/git-next/src/branch/main/README
|
|||
keywords = ["git", "cli", "server", "tool"]
|
||||
categories = ["development-tools"]
|
||||
|
||||
[workspace.lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
# pedantic = "warn"
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
# [workspace.lints.clippy]
|
||||
# pedantic = { level = "warn", priority = -1 }
|
||||
# nursery = { level = "warn", priority = -1 }
|
||||
# unwrap_used = "warn"
|
||||
# expect_used = "warn"
|
||||
|
||||
[workspace.dependencies]
|
||||
git-next-core = { path = "crates/core", version = "0.13" }
|
||||
|
|
|
@ -76,7 +76,7 @@ mockall = { workspace = true }
|
|||
|
||||
[lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
# pedantic = "warn"
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ pub(super) fn send_email(user_notification: &UserNotification, email_config: &Em
|
|||
};
|
||||
match email_config.smtp() {
|
||||
Some(smtp) => send_email_smtp(email_message, smtp),
|
||||
None => send_email_sendmail(email_message),
|
||||
None => send_email_sendmail(&email_message),
|
||||
}
|
||||
}
|
||||
|
||||
fn send_email_sendmail(email_message: EmailMessage) {
|
||||
fn send_email_sendmail(email_message: &EmailMessage) {
|
||||
use sendmail::email;
|
||||
match email::send(
|
||||
&email_message.from,
|
||||
|
@ -35,7 +35,7 @@ fn send_email_sendmail(email_message: EmailMessage) {
|
|||
&email_message.subject,
|
||||
&email_message.body,
|
||||
) {
|
||||
Ok(_) => tracing::info!("Email sent successfully!"),
|
||||
Ok(()) => tracing::info!("Email sent successfully!"),
|
||||
Err(e) => tracing::warn!("Could not send email: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ fn do_send_email_smtp(email_message: EmailMessage, smtp: &SmtpConfig) -> Result<
|
|||
.map(|response| {
|
||||
response
|
||||
.message()
|
||||
.map(|s| s.to_string())
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.map(|response| {
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct History {
|
|||
|
||||
/// Maps a user notification to when it was last seen.
|
||||
///
|
||||
/// The user notification will not be sent until after max_age_seconds from last seen.
|
||||
/// The user notification will not be sent until after `max_age_seconds` from last seen.
|
||||
///
|
||||
/// Each time we see a given user notification, the last seen time will be updated.
|
||||
items: HashMap<UserNotification, Instant>,
|
||||
|
@ -44,7 +44,7 @@ impl History {
|
|||
|
||||
pub fn prune(&mut self, now: &Instant) {
|
||||
if let Some(threshold) = now.checked_sub(self.max_age_seconds) {
|
||||
self.items.retain(|_, last_seen| *last_seen > threshold)
|
||||
self.items.retain(|_, last_seen| *last_seen > threshold);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ mod webhook;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
#[derive(Debug, Constructor)]
|
||||
pub struct AlertsActor {
|
||||
shout: Option<Shout>, // config for sending alerts to users
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//
|
||||
use git_next_core::{git::UserNotification, server::OutboundWebhook};
|
||||
use kxio::network::{NetRequest, NetUrl, RequestBody, ResponseType};
|
||||
use secrecy::ExposeSecret as _;
|
||||
use standardwebhooks::Webhook;
|
||||
|
||||
|
@ -35,7 +36,7 @@ async fn do_send_webhook(
|
|||
.expect("signature");
|
||||
tracing::info!(?signature, "");
|
||||
let url = webhook_config.url();
|
||||
use kxio::network::{NetRequest, NetUrl, RequestBody, ResponseType};
|
||||
|
||||
let net_url = NetUrl::new(url.to_string());
|
||||
let request = NetRequest::post(net_url)
|
||||
.body(RequestBody::Json(payload))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use anyhow::{Context, Result};
|
||||
use kxio::fs::FileSystem;
|
||||
|
||||
pub fn run(fs: FileSystem) -> Result<()> {
|
||||
pub fn run(fs: &FileSystem) -> Result<()> {
|
||||
let pathbuf = fs.base().join(".git-next.toml");
|
||||
if fs
|
||||
.path_exists(&pathbuf)
|
||||
|
|
|
@ -44,7 +44,7 @@ fn main() -> Result<()> {
|
|||
|
||||
match commands.command {
|
||||
Command::Init => {
|
||||
init::run(fs)?;
|
||||
init::run(&fs)?;
|
||||
}
|
||||
Command::Server(server) => match server {
|
||||
Server::Init => {
|
||||
|
|
|
@ -66,7 +66,7 @@ pub fn find_next_commit_on_dev(
|
|||
) -> (Option<Commit>, Force) {
|
||||
let mut next_commit: Option<&Commit> = None;
|
||||
let mut force = Force::No;
|
||||
for commit in dev_commit_history.iter() {
|
||||
for commit in dev_commit_history {
|
||||
if commit == next {
|
||||
break;
|
||||
};
|
||||
|
|
|
@ -36,12 +36,12 @@ impl Handler<AdvanceMain> for RepoActor {
|
|||
Err(err) => {
|
||||
warn!("advance main: {err}");
|
||||
}
|
||||
Ok(_) => match repo_config.source() {
|
||||
Ok(()) => match repo_config.source() {
|
||||
RepoConfigSource::Repo => {
|
||||
do_send(addr, LoadConfigFromRepo, self.log.as_ref());
|
||||
do_send(&addr, LoadConfigFromRepo, self.log.as_ref());
|
||||
}
|
||||
RepoConfigSource::Server => {
|
||||
do_send(addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
do_send(&addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Handler<AdvanceNext> for RepoActor {
|
|||
Ok(message_token) => {
|
||||
// pause to allow any CI checks to be started
|
||||
std::thread::sleep(self.sleep_duration);
|
||||
do_send(addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
do_send(&addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
}
|
||||
Err(err) => warn!("advance next: {err}"),
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ impl Handler<CheckCIStatus> for RepoActor {
|
|||
async move {
|
||||
let status = forge.commit_status(&next).await;
|
||||
debug!("got status: {status:?}");
|
||||
do_send(addr, ReceiveCIStatus::new((next, status)), log.as_ref());
|
||||
do_send(&addr, ReceiveCIStatus::new((next, status)), log.as_ref());
|
||||
}
|
||||
.in_current_span()
|
||||
.into_actor(self)
|
||||
|
|
|
@ -22,14 +22,14 @@ impl Handler<CloneRepo> for RepoActor {
|
|||
debug!("open okay");
|
||||
self.open_repository.replace(repository);
|
||||
if self.repo_details.repo_config.is_none() {
|
||||
do_send(ctx.address(), LoadConfigFromRepo, self.log.as_ref());
|
||||
do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref());
|
||||
} else {
|
||||
do_send(ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
||||
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
logger(self.log.as_ref(), "open failed");
|
||||
warn!("Could not open repo: {err:?}")
|
||||
warn!("Could not open repo: {err:?}");
|
||||
}
|
||||
}
|
||||
debug!("Handler: CloneRepo: finish");
|
||||
|
|
|
@ -28,7 +28,9 @@ impl Handler<LoadConfigFromRepo> for RepoActor {
|
|||
let log = self.log.clone();
|
||||
async move {
|
||||
match load::config_from_repository(repo_details, &*open_repository).await {
|
||||
Ok(repo_config) => do_send(addr, ReceiveRepoConfig::new(repo_config), log.as_ref()),
|
||||
Ok(repo_config) => {
|
||||
do_send(&addr, ReceiveRepoConfig::new(repo_config), log.as_ref());
|
||||
}
|
||||
Err(err) => notify_user(
|
||||
notify_user_recipient.as_ref(),
|
||||
UserNotification::RepoConfigLoadFailure {
|
||||
|
|
|
@ -26,11 +26,11 @@ impl Handler<ReceiveCIStatus> for RepoActor {
|
|||
debug!(?status, "");
|
||||
match status {
|
||||
Status::Pass => {
|
||||
do_send(addr, AdvanceMain::new(next), self.log.as_ref());
|
||||
do_send(&addr, AdvanceMain::new(next), self.log.as_ref());
|
||||
}
|
||||
Status::Pending => {
|
||||
std::thread::sleep(sleep_duration);
|
||||
do_send(addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
do_send(&addr, ValidateRepo::new(message_token), self.log.as_ref());
|
||||
}
|
||||
Status::Fail => {
|
||||
tracing::warn!("Checks have failed");
|
||||
|
@ -44,7 +44,7 @@ impl Handler<ReceiveCIStatus> for RepoActor {
|
|||
log.as_ref(),
|
||||
);
|
||||
delay_send(
|
||||
addr,
|
||||
&addr,
|
||||
sleep_duration,
|
||||
ValidateRepo::new(message_token),
|
||||
self.log.as_ref(),
|
||||
|
|
|
@ -15,6 +15,6 @@ impl Handler<ReceiveRepoConfig> for RepoActor {
|
|||
let repo_config = msg.unwrap();
|
||||
self.repo_details.repo_config.replace(repo_config);
|
||||
|
||||
do_send(ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
||||
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ impl Handler<RegisterWebhook> for RepoActor {
|
|||
Ok(registered_webhook) => {
|
||||
debug!(?registered_webhook, "");
|
||||
do_send(
|
||||
addr,
|
||||
&addr,
|
||||
WebhookRegistered::from(registered_webhook),
|
||||
log.as_ref(),
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ impl Handler<UnRegisterWebhook> for RepoActor {
|
|||
debug!("unregistering webhook");
|
||||
async move {
|
||||
match forge.unregister_webhook(&webhook_id).await {
|
||||
Ok(_) => debug!("unregistered webhook"),
|
||||
Ok(()) => debug!("unregistered webhook"),
|
||||
Err(err) => warn!(?err, "unregistering webhook"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
//
|
||||
use actix::prelude::*;
|
||||
|
||||
use derive_more::Deref as _;
|
||||
use tracing::{debug, instrument, Instrument as _};
|
||||
|
||||
use crate::repo::{
|
||||
|
@ -15,7 +14,7 @@ use git_next_core::git::validation::positions::{validate_positions, Error, Posit
|
|||
impl Handler<ValidateRepo> for RepoActor {
|
||||
type Result = ();
|
||||
|
||||
#[instrument(name = "RepoActor::ValidateRepo", skip_all, fields(repo = %self.repo_details, token = %msg.deref()))]
|
||||
#[instrument(name = "RepoActor::ValidateRepo", skip_all, fields(repo = %self.repo_details, token = %&*msg))]
|
||||
fn handle(&mut self, msg: ValidateRepo, ctx: &mut Self::Context) -> Self::Result {
|
||||
logger(self.log.as_ref(), "start: ValidateRepo");
|
||||
|
||||
|
@ -64,17 +63,17 @@ impl Handler<ValidateRepo> for RepoActor {
|
|||
}) => {
|
||||
debug!(%main, %next, %dev, "positions");
|
||||
if next_is_valid && next != main {
|
||||
do_send(ctx.address(), CheckCIStatus::new(next), self.log.as_ref());
|
||||
do_send(&ctx.address(), CheckCIStatus::new(next), self.log.as_ref());
|
||||
} else if next != dev {
|
||||
do_send(
|
||||
ctx.address(),
|
||||
&ctx.address(),
|
||||
AdvanceNext::new(AdvanceNextPayload {
|
||||
next,
|
||||
main,
|
||||
dev_commit_history,
|
||||
}),
|
||||
self.log.as_ref(),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ impl Handler<ValidateRepo> for RepoActor {
|
|||
logger(log.as_ref(), "before sleep");
|
||||
actix_rt::time::sleep(sleep_duration).await;
|
||||
logger(log.as_ref(), "after sleep");
|
||||
do_send(addr, ValidateRepo::new(message_token), log.as_ref());
|
||||
do_send(&addr, ValidateRepo::new(message_token), log.as_ref());
|
||||
}
|
||||
.in_current_span()
|
||||
.into_actor(self)
|
||||
|
|
|
@ -6,7 +6,7 @@ use tracing::{info, instrument, warn};
|
|||
use crate::repo::{
|
||||
do_send, logger,
|
||||
messages::{ValidateRepo, WebhookNotification},
|
||||
RepoActor, RepoActorLog,
|
||||
ActorLog, RepoActor,
|
||||
};
|
||||
|
||||
use git_next_core::{
|
||||
|
@ -54,7 +54,7 @@ impl Handler<WebhookNotification> for RepoActor {
|
|||
Some(Branch::Main) => {
|
||||
if handle_push(
|
||||
push,
|
||||
config.branches().main(),
|
||||
&config.branches().main(),
|
||||
&mut self.last_main_commit,
|
||||
self.log.as_ref(),
|
||||
)
|
||||
|
@ -66,7 +66,7 @@ impl Handler<WebhookNotification> for RepoActor {
|
|||
Some(Branch::Next) => {
|
||||
if handle_push(
|
||||
push,
|
||||
config.branches().next(),
|
||||
&config.branches().next(),
|
||||
&mut self.last_next_commit,
|
||||
self.log.as_ref(),
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ impl Handler<WebhookNotification> for RepoActor {
|
|||
Some(Branch::Dev) => {
|
||||
if handle_push(
|
||||
push,
|
||||
config.branches().dev(),
|
||||
&config.branches().dev(),
|
||||
&mut self.last_dev_commit,
|
||||
self.log.as_ref(),
|
||||
)
|
||||
|
@ -95,7 +95,7 @@ impl Handler<WebhookNotification> for RepoActor {
|
|||
"New commit"
|
||||
);
|
||||
do_send(
|
||||
ctx.address(),
|
||||
&ctx.address(),
|
||||
ValidateRepo::new(message_token),
|
||||
self.log.as_ref(),
|
||||
);
|
||||
|
@ -106,7 +106,7 @@ fn validate_notification(
|
|||
msg: &WebhookNotification,
|
||||
webhook_auth: Option<&WebhookAuth>,
|
||||
forge: &dyn ForgeLike,
|
||||
log: Option<&RepoActorLog>,
|
||||
log: Option<&ActorLog>,
|
||||
) -> Result<(), ()> {
|
||||
let Some(expected_authorization) = webhook_auth else {
|
||||
logger(log, "server has no auth token");
|
||||
|
@ -131,9 +131,9 @@ fn validate_notification(
|
|||
|
||||
fn handle_push(
|
||||
push: Push,
|
||||
branch: BranchName,
|
||||
branch: &BranchName,
|
||||
last_commit: &mut Option<Commit>,
|
||||
log: Option<&RepoActorLog>,
|
||||
log: Option<&ActorLog>,
|
||||
) -> Result<(), ()> {
|
||||
logger(log, "message is for dev branch");
|
||||
let commit = Commit::from(push);
|
||||
|
|
|
@ -15,7 +15,7 @@ impl Handler<WebhookRegistered> for RepoActor {
|
|||
self.webhook_id.replace(msg.webhook_id().clone());
|
||||
self.webhook_auth.replace(msg.webhook_auth().clone());
|
||||
do_send(
|
||||
ctx.address(),
|
||||
&ctx.address(),
|
||||
ValidateRepo::new(self.message_token),
|
||||
self.log.as_ref(),
|
||||
);
|
||||
|
|
|
@ -46,7 +46,7 @@ Primarily used by [ValidateRepo] to reduce duplicate messages. The token is incr
|
|||
received, marking that message the latest, and causing any previous messages still being processed to be dropped when
|
||||
they next send a [ValidateRepo] message."#);
|
||||
impl MessageToken {
|
||||
pub const fn next(&self) -> Self {
|
||||
pub const fn next(self) -> Self {
|
||||
Self(self.0 + 1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ mod notifications;
|
|||
pub mod tests;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct RepoActorLog(std::sync::Arc<std::sync::RwLock<Vec<String>>>);
|
||||
impl Deref for RepoActorLog {
|
||||
pub struct ActorLog(std::sync::Arc<std::sync::RwLock<Vec<String>>>);
|
||||
impl Deref for ActorLog {
|
||||
type Target = std::sync::Arc<std::sync::RwLock<Vec<String>>>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
@ -38,7 +38,8 @@ impl Deref for RepoActorLog {
|
|||
|
||||
/// An actor that represents a Git Repository.
|
||||
///
|
||||
/// When this actor is started it is sent the [CloneRepo] message.
|
||||
/// When this actor is started it is sent the `CloneRepo` message.
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
#[derive(Debug, derive_more::Display, derive_with::With)]
|
||||
#[display("{}:{}:{}", generation, repo_details.forge.forge_alias(), repo_details.repo_alias)]
|
||||
pub struct RepoActor {
|
||||
|
@ -56,7 +57,7 @@ pub struct RepoActor {
|
|||
open_repository: Option<Box<dyn OpenRepositoryLike>>,
|
||||
net: Network,
|
||||
forge: Box<dyn git::ForgeLike>,
|
||||
log: Option<RepoActorLog>,
|
||||
log: Option<ActorLog>,
|
||||
notify_user_recipient: Option<Recipient<NotifyUser>>,
|
||||
}
|
||||
impl RepoActor {
|
||||
|
@ -118,33 +119,35 @@ impl Actor for RepoActor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn delay_send<M>(addr: Addr<RepoActor>, delay: Duration, msg: M, log: Option<&RepoActorLog>)
|
||||
pub fn delay_send<M>(addr: &Addr<RepoActor>, delay: Duration, msg: M, log: Option<&ActorLog>)
|
||||
where
|
||||
M: actix::Message + Send + 'static + std::fmt::Debug,
|
||||
RepoActor: actix::Handler<M>,
|
||||
<M as actix::Message>::Result: Send,
|
||||
{
|
||||
let log_message = format!("send-after-delay: {:?}", msg);
|
||||
let log_message = format!("send-after-delay: {msg:?}");
|
||||
tracing::debug!(log_message);
|
||||
logger(log, log_message);
|
||||
std::thread::sleep(delay);
|
||||
do_send(addr, msg, log)
|
||||
do_send(addr, msg, log);
|
||||
}
|
||||
|
||||
pub fn do_send<M>(_addr: Addr<RepoActor>, msg: M, log: Option<&RepoActorLog>)
|
||||
pub fn do_send<M>(addr: &Addr<RepoActor>, msg: M, log: Option<&ActorLog>)
|
||||
where
|
||||
M: actix::Message + Send + 'static + std::fmt::Debug,
|
||||
RepoActor: actix::Handler<M>,
|
||||
<M as actix::Message>::Result: Send,
|
||||
{
|
||||
let log_message = format!("send: {:?}", msg);
|
||||
let log_message = format!("send: {msg:?}");
|
||||
tracing::debug!(log_message);
|
||||
logger(log, log_message);
|
||||
#[cfg(not(test))]
|
||||
_addr.do_send(msg)
|
||||
if cfg!(not(test)) {
|
||||
// #[cfg(not(test))]
|
||||
addr.do_send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn logger(log: Option<&RepoActorLog>, message: impl Into<String>) {
|
||||
pub fn logger(log: Option<&ActorLog>, message: impl Into<String>) {
|
||||
if let Some(log) = log {
|
||||
let message: String = message.into();
|
||||
tracing::debug!(message);
|
||||
|
@ -154,10 +157,10 @@ pub fn logger(log: Option<&RepoActorLog>, message: impl Into<String>) {
|
|||
pub fn notify_user(
|
||||
recipient: Option<&Recipient<NotifyUser>>,
|
||||
user_notification: UserNotification,
|
||||
log: Option<&RepoActorLog>,
|
||||
log: Option<&ActorLog>,
|
||||
) {
|
||||
let msg = NotifyUser::from(user_notification);
|
||||
let log_message = format!("send: {:?}", msg);
|
||||
let log_message = format!("send: {msg:?}");
|
||||
tracing::debug!(log_message);
|
||||
logger(log, log_message);
|
||||
if let Some(recipient) = &recipient {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
//
|
||||
use derive_more::Deref as _;
|
||||
|
||||
use crate::repo::messages::NotifyUser;
|
||||
|
||||
|
@ -10,7 +9,7 @@ use serde_json::json;
|
|||
impl NotifyUser {
|
||||
pub fn as_json(&self, timestamp: time::OffsetDateTime) -> serde_json::Value {
|
||||
let timestamp = timestamp.unix_timestamp().to_string();
|
||||
match self.deref() {
|
||||
match &**self {
|
||||
UserNotification::CICheckFailed {
|
||||
forge_alias,
|
||||
repo_alias,
|
||||
|
|
|
@ -179,10 +179,10 @@ pub fn a_repo_actor(
|
|||
repository_factory: Box<dyn RepositoryFactory>,
|
||||
forge: Box<dyn ForgeLike>,
|
||||
net: kxio::network::Network,
|
||||
) -> (RepoActor, RepoActorLog) {
|
||||
) -> (RepoActor, ActorLog) {
|
||||
let listen_url = given::a_listen_url();
|
||||
let generation = Generation::default();
|
||||
let log = RepoActorLog::default();
|
||||
let log = ActorLog::default();
|
||||
let actors_log = log.clone();
|
||||
(
|
||||
RepoActor::new(
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
git,
|
||||
repo::{
|
||||
messages::{CloneRepo, MessageToken},
|
||||
RepoActor, RepoActorLog,
|
||||
ActorLog, RepoActor,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ mod handlers;
|
|||
mod load;
|
||||
mod when;
|
||||
|
||||
impl RepoActorLog {
|
||||
impl ActorLog {
|
||||
pub fn no_message_contains(&self, needle: impl AsRef<str> + std::fmt::Display) -> TestResult {
|
||||
if self.find_in_messages(needle.as_ref())? {
|
||||
error!(?self, "");
|
||||
|
|
|
@ -5,7 +5,7 @@ pub fn start_actor(
|
|||
repository_factory: MockRepositoryFactory,
|
||||
repo_details: RepoDetails,
|
||||
forge: Box<dyn ForgeLike>,
|
||||
) -> (actix::Addr<RepoActor>, RepoActorLog) {
|
||||
) -> (actix::Addr<RepoActor>, ActorLog) {
|
||||
let (actor, log) = given::a_repo_actor(
|
||||
repo_details,
|
||||
Box::new(repository_factory),
|
||||
|
@ -19,7 +19,7 @@ pub fn start_actor_with_open_repository(
|
|||
open_repository: Box<dyn OpenRepositoryLike>,
|
||||
repo_details: RepoDetails,
|
||||
forge: Box<dyn ForgeLike>,
|
||||
) -> (actix::Addr<RepoActor>, RepoActorLog) {
|
||||
) -> (actix::Addr<RepoActor>, ActorLog) {
|
||||
let (actor, log) = given::a_repo_actor(repo_details, mock(), forge, given::a_network().into());
|
||||
let actor = actor.with_open_repository(Some(open_repository));
|
||||
(actor.start(), log)
|
||||
|
|
|
@ -14,7 +14,7 @@ impl Handler<FileUpdated> for ServerActor {
|
|||
fn handle(&mut self, _msg: FileUpdated, ctx: &mut Self::Context) -> Self::Result {
|
||||
match ServerConfig::load(&self.fs) {
|
||||
Ok(server_config) => self.do_send(ReceiveServerConfig::new(server_config), ctx),
|
||||
Err(err) => self.abort(ctx, format!("Failed to load config file. Error: {}", err)),
|
||||
Err(err) => self.abort(ctx, format!("Failed to load config file. Error: {err}")),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ impl Handler<ReceiveValidServerConfig> for ServerActor {
|
|||
info!("Starting Webhook Server...");
|
||||
let webhook_router = WebhookRouter::default().start();
|
||||
let listen_url = server_config.listen().url();
|
||||
let alerts = self.alerts.clone();
|
||||
let notify_user_recipient = self.alerts.clone().recipient();
|
||||
// Forge Actors
|
||||
for (forge_alias, forge_config) in server_config.forges() {
|
||||
let repo_actors = self
|
||||
|
@ -43,7 +43,7 @@ impl Handler<ReceiveValidServerConfig> for ServerActor {
|
|||
forge_alias.clone(),
|
||||
&server_storage,
|
||||
listen_url,
|
||||
alerts.clone().recipient(),
|
||||
¬ify_user_recipient,
|
||||
)
|
||||
.into_iter()
|
||||
.map(|a| self.start_actor(a))
|
||||
|
@ -58,10 +58,10 @@ impl Handler<ReceiveValidServerConfig> for ServerActor {
|
|||
)
|
||||
})
|
||||
.for_each(|msg| webhook_router.do_send(msg));
|
||||
repo_actors.into_iter().for_each(|(repo_alias, addr)| {
|
||||
for (repo_alias, addr) in repo_actors {
|
||||
self.repo_actors
|
||||
.insert((forge_alias.clone(), repo_alias), addr);
|
||||
});
|
||||
}
|
||||
}
|
||||
let webhook_actor_addr =
|
||||
WebhookActor::new(socket_address, webhook_router.recipient()).start();
|
||||
|
|
|
@ -47,6 +47,7 @@ pub enum Error {
|
|||
}
|
||||
type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
#[derive(derive_with::With)]
|
||||
#[with(message_log)]
|
||||
pub struct ServerActor {
|
||||
|
@ -116,7 +117,7 @@ impl ServerActor {
|
|||
forge_name: ForgeAlias,
|
||||
server_storage: &ServerStorage,
|
||||
listen_url: &ListenUrl,
|
||||
notify_user_recipient: Recipient<NotifyUser>,
|
||||
notify_user_recipient: &Recipient<NotifyUser>,
|
||||
) -> Vec<(ForgeAlias, RepoAlias, RepoActor)> {
|
||||
let span =
|
||||
tracing::info_span!("create_forge_repos", name = %forge_name, config = %forge_config);
|
||||
|
|
|
@ -8,7 +8,7 @@ mod init {
|
|||
let file = fs.base().join(".git-next.toml");
|
||||
fs.file_write(&file, "contents")?;
|
||||
|
||||
crate::init::run(fs.clone())?;
|
||||
crate::init::run(&fs)?;
|
||||
|
||||
assert_eq!(
|
||||
fs.file_read_to_string(&file)?,
|
||||
|
@ -23,7 +23,7 @@ mod init {
|
|||
fn should_create_default_file_if_not_exists() -> TestResult {
|
||||
let fs = kxio::fs::temp()?;
|
||||
|
||||
crate::init::run(fs.clone())?;
|
||||
crate::init::run(&fs)?;
|
||||
|
||||
let file = fs.base().join(".git-next.toml");
|
||||
|
||||
|
|
Loading…
Reference in a new issue