feat: isolate ForgeJo behind default feature 'forgejo'
All checks were successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful

This commit is contained in:
Paul Campbell 2024-04-12 20:53:55 +01:00
parent 9df732ce97
commit 1ffa8366e0
6 changed files with 11 additions and 0 deletions

View file

@ -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]

View file

@ -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
}

View file

@ -11,6 +11,7 @@ use super::{LoadedConfig, RepoActor};
pub async fn load(details: RepoDetails, addr: Addr<RepoActor>, net: Network) {
let config = match details.forge.forge_type {
#[cfg(feature = "forgejo")]
ForgeType::ForgeJo => forge::forgejo::config::load(&details, &net).await,
};
match config {

View file

@ -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
}

View file

@ -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(

View file

@ -1,5 +1,6 @@
use std::fmt::{Display, Formatter};
#[cfg(feature = "forgejo")]
pub mod forgejo;
#[cfg(test)]