refactor: merge forge crate into cli crate
This commit is contained in:
parent
c1981d862c
commit
57458173d0
10 changed files with 47 additions and 83 deletions
|
@ -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"
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
31
crates/cli/src/forge/mod.rs
Normal file
31
crates/cli/src/forge/mod.rs
Normal file
|
@ -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<dyn ForgeLike> {
|
||||
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;
|
|
@ -1,5 +1,6 @@
|
|||
//
|
||||
mod file_watcher;
|
||||
mod forge;
|
||||
mod init;
|
||||
mod repo;
|
||||
mod server;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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<dyn git::ForgeLike> {
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue