Compare commits

..

No commits in common. "9e37c073c2564e0d2c8de7068beb9707cd7f6a94" and "64cbe36dac1a893ca892d04c9815dc39eb9ac5f1" have entirely different histories.

4 changed files with 36 additions and 32 deletions

View file

@ -2,7 +2,7 @@ use std::time::Duration;
use actix::prelude::*;
use git_next_config as config;
use git_next_config::RepoConfig;
use git_next_forge as forge;
use git_next_git as git;
use tracing::{info, warn};
@ -14,7 +14,7 @@ use crate::{MessageToken, ValidateRepo};
pub async fn advance_next(
next: git::Commit,
dev_commit_history: Vec<git::Commit>,
repo_config: config::RepoConfig,
repo_config: RepoConfig,
forge: forge::Forge,
repository: git::OpenRepository,
addr: Addr<super::RepoActor>,
@ -78,7 +78,7 @@ pub fn find_next_commit_on_dev(
#[tracing::instrument(fields(next), skip_all)]
pub async fn advance_main(
next: git::Commit,
repo_config: &config::RepoConfig,
repo_config: &RepoConfig,
forge: &forge::Forge,
repository: &git::OpenRepository,
) {

View file

@ -0,0 +1,25 @@
use actix::prelude::*;
use git_next_forge as forge;
use git_next_git as git;
use tracing::{error, info};
use crate::load;
use super::{LoadedConfig, RepoActor};
/// Loads the [RepoConfig] from the `.git-next.toml` file in the repository
#[tracing::instrument(skip_all, fields(branch = %repo_details.branch))]
pub async fn load(repo_details: git::RepoDetails, addr: Addr<RepoActor>, forge: forge::Forge) {
info!("Loading .git-next.toml from repo");
let repo_config = match load::load(&repo_details, &forge).await {
Ok(repo_config) => repo_config,
Err(err) => {
error!(?err, "Failed to load config");
return;
}
};
info!("Loaded .git-next.toml from repo");
addr.do_send(LoadedConfig(repo_config));
}

View file

@ -1,4 +1,5 @@
mod branch;
pub mod config;
mod load;
pub mod status;
pub mod webhook;
@ -10,8 +11,6 @@ use std::time::Duration;
use actix::prelude::*;
use crate as repo_actor;
use git_next_config as config;
use git_next_forge as forge;
use git_next_git as git;
@ -24,7 +23,7 @@ pub struct RepoActor {
generation: git::Generation,
message_token: MessageToken,
details: git::RepoDetails,
webhook: config::server::Webhook,
webhook: git_next_config::server::Webhook,
webhook_id: Option<webhook::WebhookId>, // INFO: if [None] then no webhook is configured
webhook_auth: Option<webhook::WebhookAuth>, // INFO: if [None] then no webhook is configured
last_main_commit: Option<git::Commit>,
@ -37,17 +36,17 @@ pub struct RepoActor {
impl RepoActor {
pub fn new(
details: git::RepoDetails,
webhook: config::server::Webhook,
webhook: git_next_config::server::Webhook,
generation: git::Generation,
net: Network,
repo: git::Repository,
) -> Self {
let forge = match details.forge.forge_type() {
#[cfg(feature = "forgejo")]
config::ForgeType::ForgeJo => {
git_next_config::ForgeType::ForgeJo => {
forge::Forge::new_forgejo(details.clone(), net.clone(), repo)
}
config::ForgeType::MockForge => forge::Forge::new_mock(),
git_next_config::ForgeType::MockForge => forge::Forge::new_mock(),
};
debug!(?forge, "new");
Self {
@ -121,7 +120,7 @@ impl Handler<LoadConfigFromRepo> for RepoActor {
let details = self.details.clone();
let addr = ctx.address();
let forge = self.forge.clone();
repo_actor::load::load_file(details, addr, forge)
config::load(details, addr, forge)
.in_current_span()
.into_actor(self)
.wait(ctx);

View file

@ -1,30 +1,10 @@
//
use actix::prelude::*;
use tracing::{error, info};
use git_next_config as config;
use git_next_forge as forge;
use git_next_git as git;
use super::{LoadedConfig, RepoActor};
use tracing::error;
/// Loads the [RepoConfig] from the `.git-next.toml` file in the repository
#[tracing::instrument(skip_all, fields(branch = %repo_details.branch))]
pub async fn load_file(repo_details: git::RepoDetails, addr: Addr<RepoActor>, forge: forge::Forge) {
info!("Loading .git-next.toml from repo");
let repo_config = match load(&repo_details, &forge).await {
Ok(repo_config) => repo_config,
Err(err) => {
error!(?err, "Failed to load config");
return;
}
};
info!("Loaded .git-next.toml from repo");
addr.do_send(LoadedConfig(repo_config));
}
async fn load(
pub async fn load(
details: &git::RepoDetails,
forge: &forge::Forge,
) -> Result<config::RepoConfig, Error> {