diff --git a/Cargo.toml b/Cargo.toml index 73ce6638..8b63823b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ documentation = "https://git.kemitix.net/kemitix/git-next/src/branch/main/README keywords = ["git", "cli", "server", "tool"] categories = ["development-tools"] - [workspace.lints.clippy] nursery = { level = "warn", priority = -1 } # pedantic = "warn" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 0d888e84..6d57d42a 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -11,10 +11,16 @@ documentation = { workspace = true } keywords = { workspace = true } categories = { workspace = true } +[features] +default = ["forgejo", "github"] +forgejo = ["git-next-forge-forgejo"] +github = ["git-next-forge-github"] + [dependencies] git-next-core = { workspace = true } git-next-server-actor = { workspace = true } -git-next-forge = { workspace = true } +git-next-forge-forgejo = { workspace = true, optional = true } +git-next-forge-github = { workspace = true, optional = true } # CLI parsing clap = { workspace = true } diff --git a/crates/cli/README.md b/crates/cli/README.md index d92b2495..3e359dcf 100644 --- a/crates/cli/README.md +++ b/crates/cli/README.md @@ -520,11 +520,8 @@ The following diagram shows the dependency between the crates that make up `git- stateDiagram-v2 cli --> core - cli --> forge - - forge --> core - forge --> forge_forgejo - forge --> forge_github + cli --> forge_forgejo + cli --> forge_github forge_forgejo --> core diff --git a/crates/cli/src/forge/mod.rs b/crates/cli/src/forge/mod.rs new file mode 100644 index 00000000..12f06bbb --- /dev/null +++ b/crates/cli/src/forge/mod.rs @@ -0,0 +1,31 @@ +// +use git_next_core::{ + git::{ForgeLike, RepoDetails}, + ForgeType, +}; + +#[cfg(feature = "forgejo")] +use git_next_forge_forgejo::ForgeJo; + +#[cfg(feature = "github")] +use git_next_forge_github::Github; + +use kxio::network::Network; + +#[derive(Clone, Debug)] +pub struct Forge; + +impl Forge { + pub fn create(repo_details: RepoDetails, net: Network) -> Box { + match repo_details.forge.forge_type() { + #[cfg(feature = "forgejo")] + ForgeType::ForgeJo => Box::new(ForgeJo::new(repo_details, net)), + #[cfg(feature = "github")] + ForgeType::GitHub => Box::new(Github::new(repo_details, net)), + ForgeType::MockForge => unreachable!(), + } + } +} + +#[cfg(test)] +pub mod tests; diff --git a/crates/forge/src/tests.rs b/crates/cli/src/forge/tests.rs similarity index 100% rename from crates/forge/src/tests.rs rename to crates/cli/src/forge/tests.rs diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 9eaa9b69..bd9de7e8 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1,5 +1,6 @@ // mod file_watcher; +mod forge; mod init; mod repo; mod server; diff --git a/crates/cli/src/server/actor/mod.rs b/crates/cli/src/server/actor/mod.rs index bb24788a..f40e8fb4 100644 --- a/crates/cli/src/server/actor/mod.rs +++ b/crates/cli/src/server/actor/mod.rs @@ -10,6 +10,7 @@ mod handlers; pub mod messages; use crate::{ + forge::Forge, repo::{ messages::{CloneRepo, NotifyUser}, RepoActor, @@ -179,7 +180,7 @@ impl ServerActor { &forge_config, gitdir, ); - let forge = git_next_forge::Forge::create(repo_details.clone(), net.clone()); + let forge = Forge::create(repo_details.clone(), net.clone()); tracing::info!("Starting Repo Actor"); let actor = RepoActor::new( repo_details, diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 16ac67c5..8b837d81 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -4,50 +4,4 @@ version = { workspace = true } edition = { workspace = true } license = { workspace = true } repository = { workspace = true } -description = "Generic forge support for git-next, the trunk-based development manager" - -[features] -default = ["forgejo", "github"] -forgejo = ["git-next-forge-forgejo"] -github = ["git-next-forge-github"] - -[dependencies] -git-next-core = { workspace = true } -git-next-forge-forgejo = { workspace = true, optional = true } -git-next-forge-github = { workspace = true, optional = true } - -# logging -tracing = { workspace = true } - -# base64 decoding -base64 = { workspace = true } - -# git -async-trait = { workspace = true } - -# fs/network -kxio = { workspace = true } - -# TOML parsing -serde = { workspace = true } -serde_json = { workspace = true } -toml = { workspace = true } - -# Secrets and Password -secrecy = { workspace = true } - -# Webhooks -bytes = { workspace = true } -ulid = { workspace = true } - -# boilerplate -derive_more = { workspace = true } - -# # Actors -tokio = { workspace = true } - -[lints.clippy] -nursery = { level = "warn", priority = -1 } -# pedantic = "warn" -unwrap_used = "warn" -expect_used = "warn" +description = "[deprecated crate] Generic forge support for git-next, the trunk-based development manager" diff --git a/crates/forge/README.md b/crates/forge/README.md index ddc70e2a..b90af458 100644 --- a/crates/forge/README.md +++ b/crates/forge/README.md @@ -7,3 +7,5 @@ development workflows where each commit must pass CI before being included in the main branch. See [git-next](https://crates.io/crates/git-next) for more information. + +N.B. this crate has been merged into [git-next](https://crates.io/git-next). diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 47386dfa..0adc364c 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -1,28 +1 @@ -// -use git_next_core::{git, ForgeType}; -use kxio::network::Network; - -#[derive(Clone, Debug)] -pub enum Forge { - Mock, - - #[cfg(feature = "forgejo")] - ForgeJo(git_next_forge_forgejo::ForgeJo), - - #[cfg(feature = "github")] - Github(git_next_forge_github::Github), -} -impl Forge { - pub fn create(repo_details: git::RepoDetails, net: Network) -> Box { - match repo_details.forge.forge_type() { - #[cfg(feature = "forgejo")] - ForgeType::ForgeJo => Box::new(git_next_forge_forgejo::ForgeJo::new(repo_details, net)), - #[cfg(feature = "github")] - ForgeType::GitHub => Box::new(git_next_forge_github::Github::new(repo_details, net)), - ForgeType::MockForge => unreachable!(), - } - } -} - -#[cfg(test)] -pub mod tests; +// moved to /crates/cli/src/forge