refactor: rename config variables,etc as repo_config
This commit is contained in:
parent
ee8b1e9fce
commit
32d54cfc1c
6 changed files with 19 additions and 18 deletions
|
@ -5,13 +5,14 @@ use crate::server::{config::RepoDetails, gitforge};
|
||||||
|
|
||||||
use super::{LoadedConfig, RepoActor};
|
use super::{LoadedConfig, RepoActor};
|
||||||
|
|
||||||
|
/// Loads the [RepoConfig] from the `.git-next.toml` file in the repository
|
||||||
pub async fn load(repo_details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
|
pub async fn load(repo_details: RepoDetails, addr: Addr<RepoActor>, forge: gitforge::Forge) {
|
||||||
let config = match crate::server::config::load::load(&repo_details, &forge).await {
|
let repo_config = match crate::server::config::load::load(&repo_details, &forge).await {
|
||||||
Ok(config) => config,
|
Ok(repo_config) => repo_config,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(?err, "Failed to load config");
|
error!(?err, "Failed to load config");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addr.do_send(LoadedConfig(config));
|
addr.do_send(LoadedConfig(repo_config));
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,9 +88,9 @@ struct LoadedConfig(pub RepoConfig);
|
||||||
impl Handler<LoadedConfig> for RepoActor {
|
impl Handler<LoadedConfig> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, msg: LoadedConfig, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: LoadedConfig, ctx: &mut Self::Context) -> Self::Result {
|
||||||
let config = msg.0;
|
let repo_config = msg.0;
|
||||||
info!(%self.details, %config, "Config loaded");
|
info!(%self.details, %repo_config, "Config loaded");
|
||||||
self.details.config.replace(config);
|
self.details.repo_config.replace(repo_config);
|
||||||
if self.webhook_id.is_none() {
|
if self.webhook_id.is_none() {
|
||||||
webhook::register(
|
webhook::register(
|
||||||
self.details.clone(),
|
self.details.clone(),
|
||||||
|
@ -111,7 +111,7 @@ pub struct ValidateRepo;
|
||||||
impl Handler<ValidateRepo> for RepoActor {
|
impl Handler<ValidateRepo> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, _msg: ValidateRepo, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, _msg: ValidateRepo, ctx: &mut Self::Context) -> Self::Result {
|
||||||
if let Some(repo_config) = self.details.config.clone() {
|
if let Some(repo_config) = self.details.repo_config.clone() {
|
||||||
let forge = self.forge.clone();
|
let forge = self.forge.clone();
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
async move { forge.branches_validate_positions(repo_config, addr).await }
|
async move { forge.branches_validate_positions(repo_config, addr).await }
|
||||||
|
@ -132,7 +132,7 @@ pub struct StartMonitoring {
|
||||||
impl Handler<StartMonitoring> for RepoActor {
|
impl Handler<StartMonitoring> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, msg: StartMonitoring, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: StartMonitoring, ctx: &mut Self::Context) -> Self::Result {
|
||||||
let Some(repo_config) = self.details.config.clone() else {
|
let Some(repo_config) = self.details.repo_config.clone() else {
|
||||||
warn!("No config loaded");
|
warn!("No config loaded");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -180,7 +180,7 @@ pub struct AdvanceMainTo(pub gitforge::Commit);
|
||||||
impl Handler<AdvanceMainTo> for RepoActor {
|
impl Handler<AdvanceMainTo> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, msg: AdvanceMainTo, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: AdvanceMainTo, ctx: &mut Self::Context) -> Self::Result {
|
||||||
let Some(repo_config) = self.details.config.clone() else {
|
let Some(repo_config) = self.details.repo_config.clone() else {
|
||||||
warn!("No config loaded");
|
warn!("No config loaded");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub async fn register(
|
||||||
addr: actix::prelude::Addr<super::RepoActor>,
|
addr: actix::prelude::Addr<super::RepoActor>,
|
||||||
net: network::Network,
|
net: network::Network,
|
||||||
) {
|
) {
|
||||||
let Some(repo_config) = repo_details.config.clone() else {
|
let Some(repo_config) = repo_details.repo_config.clone() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ impl Handler<WebhookMessage> for RepoActor {
|
||||||
match serde_json::from_str::<Push>(body) {
|
match serde_json::from_str::<Push>(body) {
|
||||||
Err(err) => debug!(?err, %body, "Not a 'push'"),
|
Err(err) => debug!(?err, %body, "Not a 'push'"),
|
||||||
Ok(push) => {
|
Ok(push) => {
|
||||||
if let Some(config) = &self.details.config {
|
if let Some(config) = &self.details.repo_config {
|
||||||
match push.branch(config.branches()) {
|
match push.branch(config.branches()) {
|
||||||
None => warn!(
|
None => warn!(
|
||||||
?push,
|
?push,
|
||||||
|
|
|
@ -326,7 +326,7 @@ pub struct RepoDetails {
|
||||||
pub repo_path: RepoPath,
|
pub repo_path: RepoPath,
|
||||||
pub branch: BranchName,
|
pub branch: BranchName,
|
||||||
pub forge: ForgeDetails,
|
pub forge: ForgeDetails,
|
||||||
pub config: Option<RepoConfig>,
|
pub repo_config: Option<RepoConfig>,
|
||||||
pub gitdir: Option<GitDir>,
|
pub gitdir: Option<GitDir>,
|
||||||
}
|
}
|
||||||
impl RepoDetails {
|
impl RepoDetails {
|
||||||
|
@ -339,7 +339,7 @@ impl RepoDetails {
|
||||||
Self {
|
Self {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
repo_path: RepoPath(server_repo_config.repo.clone()),
|
repo_path: RepoPath(server_repo_config.repo.clone()),
|
||||||
config: server_repo_config.repo_config(),
|
repo_config: server_repo_config.repo_config(),
|
||||||
branch: BranchName(server_repo_config.branch.clone()),
|
branch: BranchName(server_repo_config.branch.clone()),
|
||||||
gitdir: server_repo_config.gitdir(),
|
gitdir: server_repo_config.gitdir(),
|
||||||
forge: ForgeDetails {
|
forge: ForgeDetails {
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn forge_name(n: u32) -> ForgeName {
|
||||||
pub fn repo_details(
|
pub fn repo_details(
|
||||||
n: u32,
|
n: u32,
|
||||||
forge: ForgeDetails,
|
forge: ForgeDetails,
|
||||||
config: Option<RepoConfig>,
|
repo_config: Option<RepoConfig>,
|
||||||
gitdir: Option<GitDir>,
|
gitdir: Option<GitDir>,
|
||||||
) -> RepoDetails {
|
) -> RepoDetails {
|
||||||
RepoDetails {
|
RepoDetails {
|
||||||
|
@ -40,7 +40,7 @@ pub fn repo_details(
|
||||||
gitdir,
|
gitdir,
|
||||||
branch: branch_name(n),
|
branch: branch_name(n),
|
||||||
forge,
|
forge,
|
||||||
config,
|
repo_config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ pub fn repo_alias(n: u32) -> RepoAlias {
|
||||||
RepoAlias(format!("repo-alias-{}", n))
|
RepoAlias(format!("repo-alias-{}", n))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config(n: u32) -> RepoConfig {
|
pub fn repo_config(n: u32) -> RepoConfig {
|
||||||
RepoConfig::new(RepoBranches::new(
|
RepoConfig::new(RepoBranches::new(
|
||||||
format!("main-{n}"),
|
format!("main-{n}"),
|
||||||
format!("next-{n}"),
|
format!("next-{n}"),
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn test_name() {
|
||||||
let repo_details = common::repo_details(
|
let repo_details = common::repo_details(
|
||||||
1,
|
1,
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
Some(common::config(1)),
|
Some(common::repo_config(1)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let forge = Forge::new_forgejo(repo_details, net);
|
let forge = Forge::new_forgejo(repo_details, net);
|
||||||
|
@ -35,7 +35,7 @@ async fn test_branches_get() {
|
||||||
let repo_details = common::repo_details(
|
let repo_details = common::repo_details(
|
||||||
1,
|
1,
|
||||||
common::forge_details(1, ForgeType::MockForge),
|
common::forge_details(1, ForgeType::MockForge),
|
||||||
Some(common::config(1)),
|
Some(common::repo_config(1)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue