Compare commits
2 commits
64cbe36dac
...
9e37c073c2
Author | SHA1 | Date | |
---|---|---|---|
9e37c073c2 | |||
17b1629cdf |
4 changed files with 32 additions and 36 deletions
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
|
|
||||||
use git_next_config::RepoConfig;
|
use git_next_config as config;
|
||||||
use git_next_forge as forge;
|
use git_next_forge as forge;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
@ -14,7 +14,7 @@ use crate::{MessageToken, ValidateRepo};
|
||||||
pub async fn advance_next(
|
pub async fn advance_next(
|
||||||
next: git::Commit,
|
next: git::Commit,
|
||||||
dev_commit_history: Vec<git::Commit>,
|
dev_commit_history: Vec<git::Commit>,
|
||||||
repo_config: RepoConfig,
|
repo_config: config::RepoConfig,
|
||||||
forge: forge::Forge,
|
forge: forge::Forge,
|
||||||
repository: git::OpenRepository,
|
repository: git::OpenRepository,
|
||||||
addr: Addr<super::RepoActor>,
|
addr: Addr<super::RepoActor>,
|
||||||
|
@ -78,7 +78,7 @@ pub fn find_next_commit_on_dev(
|
||||||
#[tracing::instrument(fields(next), skip_all)]
|
#[tracing::instrument(fields(next), skip_all)]
|
||||||
pub async fn advance_main(
|
pub async fn advance_main(
|
||||||
next: git::Commit,
|
next: git::Commit,
|
||||||
repo_config: &RepoConfig,
|
repo_config: &config::RepoConfig,
|
||||||
forge: &forge::Forge,
|
forge: &forge::Forge,
|
||||||
repository: &git::OpenRepository,
|
repository: &git::OpenRepository,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
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));
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
mod branch;
|
mod branch;
|
||||||
pub mod config;
|
|
||||||
mod load;
|
mod load;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
pub mod webhook;
|
pub mod webhook;
|
||||||
|
@ -11,6 +10,8 @@ use std::time::Duration;
|
||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
|
|
||||||
|
use crate as repo_actor;
|
||||||
|
use git_next_config as config;
|
||||||
use git_next_forge as forge;
|
use git_next_forge as forge;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ pub struct RepoActor {
|
||||||
generation: git::Generation,
|
generation: git::Generation,
|
||||||
message_token: MessageToken,
|
message_token: MessageToken,
|
||||||
details: git::RepoDetails,
|
details: git::RepoDetails,
|
||||||
webhook: git_next_config::server::Webhook,
|
webhook: config::server::Webhook,
|
||||||
webhook_id: Option<webhook::WebhookId>, // INFO: if [None] then no webhook is configured
|
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
|
webhook_auth: Option<webhook::WebhookAuth>, // INFO: if [None] then no webhook is configured
|
||||||
last_main_commit: Option<git::Commit>,
|
last_main_commit: Option<git::Commit>,
|
||||||
|
@ -36,17 +37,17 @@ pub struct RepoActor {
|
||||||
impl RepoActor {
|
impl RepoActor {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
details: git::RepoDetails,
|
details: git::RepoDetails,
|
||||||
webhook: git_next_config::server::Webhook,
|
webhook: config::server::Webhook,
|
||||||
generation: git::Generation,
|
generation: git::Generation,
|
||||||
net: Network,
|
net: Network,
|
||||||
repo: git::Repository,
|
repo: git::Repository,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let forge = match details.forge.forge_type() {
|
let forge = match details.forge.forge_type() {
|
||||||
#[cfg(feature = "forgejo")]
|
#[cfg(feature = "forgejo")]
|
||||||
git_next_config::ForgeType::ForgeJo => {
|
config::ForgeType::ForgeJo => {
|
||||||
forge::Forge::new_forgejo(details.clone(), net.clone(), repo)
|
forge::Forge::new_forgejo(details.clone(), net.clone(), repo)
|
||||||
}
|
}
|
||||||
git_next_config::ForgeType::MockForge => forge::Forge::new_mock(),
|
config::ForgeType::MockForge => forge::Forge::new_mock(),
|
||||||
};
|
};
|
||||||
debug!(?forge, "new");
|
debug!(?forge, "new");
|
||||||
Self {
|
Self {
|
||||||
|
@ -120,7 +121,7 @@ impl Handler<LoadConfigFromRepo> for RepoActor {
|
||||||
let details = self.details.clone();
|
let details = self.details.clone();
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let forge = self.forge.clone();
|
let forge = self.forge.clone();
|
||||||
config::load(details, addr, forge)
|
repo_actor::load::load_file(details, addr, forge)
|
||||||
.in_current_span()
|
.in_current_span()
|
||||||
.into_actor(self)
|
.into_actor(self)
|
||||||
.wait(ctx);
|
.wait(ctx);
|
||||||
|
|
|
@ -1,10 +1,30 @@
|
||||||
|
//
|
||||||
|
use actix::prelude::*;
|
||||||
|
|
||||||
|
use tracing::{error, info};
|
||||||
|
|
||||||
use git_next_config as config;
|
use git_next_config as config;
|
||||||
use git_next_forge as forge;
|
use git_next_forge as forge;
|
||||||
use git_next_git as git;
|
use git_next_git as git;
|
||||||
|
|
||||||
use tracing::error;
|
use super::{LoadedConfig, RepoActor};
|
||||||
|
|
||||||
pub async fn load(
|
/// 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(
|
||||||
details: &git::RepoDetails,
|
details: &git::RepoDetails,
|
||||||
forge: &forge::Forge,
|
forge: &forge::Forge,
|
||||||
) -> Result<config::RepoConfig, Error> {
|
) -> Result<config::RepoConfig, Error> {
|
||||||
|
|
Loading…
Reference in a new issue