From 1ffa8366e0ef919460464666a042d575822b8919 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 12 Apr 2024 20:53:55 +0100 Subject: [PATCH] feat: isolate ForgeJo behind default feature 'forgejo' --- Cargo.toml | 4 ++++ src/server/actors/repo/branch.rs | 1 + src/server/actors/repo/config.rs | 1 + src/server/actors/repo/status.rs | 1 + src/server/config.rs | 3 +++ src/server/forge/mod.rs | 1 + 6 files changed, 11 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index b1601108..6b01c016 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,10 @@ name = "git-next" version = "0.1.2" edition = "2021" +[features] +default = ["forgejo"] +forgejo = [] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/src/server/actors/repo/branch.rs b/src/server/actors/repo/branch.rs index 16801df0..917df8b7 100644 --- a/src/server/actors/repo/branch.rs +++ b/src/server/actors/repo/branch.rs @@ -16,6 +16,7 @@ pub async fn validate_positions( net: network::Network, ) { let commit_histories = match repo_details.forge.forge_type { + #[cfg(feature = "forgejo")] config::ForgeType::ForgeJo => { forge::forgejo::get_commit_histories(&repo_details, &config, &net).await } diff --git a/src/server/actors/repo/config.rs b/src/server/actors/repo/config.rs index 604c2542..4c561687 100644 --- a/src/server/actors/repo/config.rs +++ b/src/server/actors/repo/config.rs @@ -11,6 +11,7 @@ use super::{LoadedConfig, RepoActor}; pub async fn load(details: RepoDetails, addr: Addr, net: Network) { let config = match details.forge.forge_type { + #[cfg(feature = "forgejo")] ForgeType::ForgeJo => forge::forgejo::config::load(&details, &net).await, }; match config { diff --git a/src/server/actors/repo/status.rs b/src/server/actors/repo/status.rs index 15bcfca7..158608ea 100644 --- a/src/server/actors/repo/status.rs +++ b/src/server/actors/repo/status.rs @@ -18,6 +18,7 @@ pub async fn check_next( ) { // get the status - pass, fail, pending (all others map to fail, e.g. error) let status = match repo_details.forge.forge_type { + #[cfg(feature = "forgejo")] ForgeType::ForgeJo => { forge::forgejo::get_commit_status(next.clone(), &repo_details, net).await } diff --git a/src/server/config.rs b/src/server/config.rs index b138a5ac..b77b0a93 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -253,6 +253,7 @@ impl Display for RepoDetails { #[derive(Clone, Debug, PartialEq, Eq, Deserialize)] pub enum ForgeType { + #[cfg(feature = "forgejo")] ForgeJo, // Gitea, // GitHub, @@ -265,6 +266,7 @@ impl Display for ForgeType { } } +#[cfg(feature = "forgejo")] #[cfg(test)] mod tests { @@ -273,6 +275,7 @@ mod tests { use super::*; #[test] + #[cfg(feature = "forgejo")] fn test_server_config_load() -> Result<(), OneOf<(std::io::Error, toml::de::Error)>> { let fs = FileSystem::new_temp().map_err(OneOf::new)?; fs.write_file( diff --git a/src/server/forge/mod.rs b/src/server/forge/mod.rs index 677d7214..bcb80d83 100644 --- a/src/server/forge/mod.rs +++ b/src/server/forge/mod.rs @@ -1,5 +1,6 @@ use std::fmt::{Display, Formatter}; +#[cfg(feature = "forgejo")] pub mod forgejo; #[cfg(test)]