From 52de3ef86efb364d466519041b60382565d544fb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 23 Jan 2025 08:23:37 +0000 Subject: [PATCH] refactor: merge forgejo crate into cli crate --- Cargo.lock | 19 +------- Cargo.toml | 1 - crates/cli/Cargo.toml | 7 ++- crates/cli/src/forge/mod.rs | 2 +- .../lib.rs => cli/src/forges/forgejo/mod.rs} | 0 .../src => cli/src/forges/forgejo}/tests.rs | 3 +- .../src/forges/forgejo}/webhook/list.rs | 2 +- .../src/forges/forgejo}/webhook/mod.rs | 0 .../src/forges/forgejo}/webhook/parser.rs | 2 +- .../src/forges/forgejo}/webhook/register.rs | 11 +++-- .../src/forges/forgejo}/webhook/unregister.rs | 0 crates/cli/src/forges/mod.rs | 3 ++ crates/cli/src/main.rs | 2 + crates/forge-forgejo/Cargo.toml | 43 ------------------- crates/forge-forgejo/README.md | 9 ---- 15 files changed, 24 insertions(+), 80 deletions(-) rename crates/{forge-forgejo/src/lib.rs => cli/src/forges/forgejo/mod.rs} (100%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/tests.rs (99%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/webhook/list.rs (97%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/webhook/mod.rs (100%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/webhook/parser.rs (89%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/webhook/register.rs (91%) rename crates/{forge-forgejo/src => cli/src/forges/forgejo}/webhook/unregister.rs (100%) create mode 100644 crates/cli/src/forges/mod.rs delete mode 100644 crates/forge-forgejo/Cargo.toml delete mode 100644 crates/forge-forgejo/README.md diff --git a/Cargo.lock b/Cargo.lock index 3c79ce1..dae5e21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1059,6 +1059,7 @@ version = "0.14.1" dependencies = [ "anyhow", "assert2", + "async-trait", "bon", "bytes", "chrono", @@ -1069,7 +1070,6 @@ dependencies = [ "directories", "git-conventional", "git-next-core", - "git-next-forge-forgejo", "git-next-forge-github", "kameo", "kxio", @@ -1085,6 +1085,7 @@ dependencies = [ "rstest 0.24.0", "secrecy", "sendmail", + "serde", "serde_json", "standardwebhooks", "test-log", @@ -1127,22 +1128,6 @@ dependencies = [ "ulid", ] -[[package]] -name = "git-next-forge-forgejo" -version = "0.14.1" -dependencies = [ - "assert2", - "async-trait", - "git-next-core", - "kxio", - "rand", - "secrecy", - "serde", - "serde_json", - "tokio", - "tracing", -] - [[package]] name = "git-next-forge-github" version = "0.14.1" diff --git a/Cargo.toml b/Cargo.toml index b0a7d5c..588480f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ categories = ["development-tools"] [workspace.dependencies] git-next-core = { path = "crates/core", version = "0.14" } -git-next-forge-forgejo = { path = "crates/forge-forgejo", version = "0.14" } git-next-forge-github = { path = "crates/forge-github", version = "0.14" } # TUI diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 3c23cdd..162ed36 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -14,7 +14,7 @@ categories = { workspace = true } [features] # default = ["forgejo", "github"] default = ["forgejo", "github", "tui"] -forgejo = ["git-next-forge-forgejo"] +forgejo = [] github = ["git-next-forge-github"] tui = [ "ratatui", @@ -27,7 +27,6 @@ tui = [ [dependencies] git-next-core = { workspace = true } -git-next-forge-forgejo = { workspace = true, optional = true } git-next-forge-github = { workspace = true, optional = true } # TUI @@ -55,6 +54,7 @@ git-conventional = { workspace = true } # TOML parsing toml = { workspace = true } +serde = { workspace = true } # Actors kameo = { workspace = true } @@ -86,6 +86,9 @@ sendmail = { workspace = true } # desktop notifications notifica = { workspace = true } +# git +async-trait = { workspace = true } + [dev-dependencies] # Testing assert2 = { workspace = true } diff --git a/crates/cli/src/forge/mod.rs b/crates/cli/src/forge/mod.rs index fad74e3..0198305 100644 --- a/crates/cli/src/forge/mod.rs +++ b/crates/cli/src/forge/mod.rs @@ -2,7 +2,7 @@ use git_next_core::git::{ForgeLike, RepoDetails}; #[cfg(feature = "forgejo")] -use git_next_forge_forgejo::ForgeJo; +use crate::forges::forgejo::ForgeJo; #[cfg(feature = "github")] use git_next_forge_github::Github; diff --git a/crates/forge-forgejo/src/lib.rs b/crates/cli/src/forges/forgejo/mod.rs similarity index 100% rename from crates/forge-forgejo/src/lib.rs rename to crates/cli/src/forges/forgejo/mod.rs diff --git a/crates/forge-forgejo/src/tests.rs b/crates/cli/src/forges/forgejo/tests.rs similarity index 99% rename from crates/forge-forgejo/src/tests.rs rename to crates/cli/src/forges/forgejo/tests.rs index 31d4d16..b6120da 100644 --- a/crates/forge-forgejo/src/tests.rs +++ b/crates/cli/src/forges/forgejo/tests.rs @@ -1,7 +1,8 @@ // #![allow(clippy::expect_used)] // used with mock net -use crate::ForgeJo; +use crate::forges::forgejo::ForgeJo; + use git_next_core::{ git::{self, forge::commit::Status, ForgeLike as _}, server::{ListenUrl, RepoListenUrl}, diff --git a/crates/forge-forgejo/src/webhook/list.rs b/crates/cli/src/forges/forgejo/webhook/list.rs similarity index 97% rename from crates/forge-forgejo/src/webhook/list.rs rename to crates/cli/src/forges/forgejo/webhook/list.rs index 734109f..206718d 100644 --- a/crates/forge-forgejo/src/webhook/list.rs +++ b/crates/cli/src/forges/forgejo/webhook/list.rs @@ -2,7 +2,7 @@ use git_next_core::{git, server::RepoListenUrl, WebhookId}; use kxio::net::Net; -use crate::webhook::Hook; +use crate::forges::forgejo::webhook::Hook; pub async fn list( repo_details: &git::RepoDetails, diff --git a/crates/forge-forgejo/src/webhook/mod.rs b/crates/cli/src/forges/forgejo/webhook/mod.rs similarity index 100% rename from crates/forge-forgejo/src/webhook/mod.rs rename to crates/cli/src/forges/forgejo/webhook/mod.rs diff --git a/crates/forge-forgejo/src/webhook/parser.rs b/crates/cli/src/forges/forgejo/webhook/parser.rs similarity index 89% rename from crates/forge-forgejo/src/webhook/parser.rs rename to crates/cli/src/forges/forgejo/webhook/parser.rs index 25f0c2d..a934aa5 100644 --- a/crates/forge-forgejo/src/webhook/parser.rs +++ b/crates/cli/src/forges/forgejo/webhook/parser.rs @@ -1,5 +1,5 @@ // -use crate as forgejo; +use crate::forges::forgejo; use git_next_core::{git, webhook}; diff --git a/crates/forge-forgejo/src/webhook/register.rs b/crates/cli/src/forges/forgejo/webhook/register.rs similarity index 91% rename from crates/forge-forgejo/src/webhook/register.rs rename to crates/cli/src/forges/forgejo/webhook/register.rs index ee96972..f735073 100644 --- a/crates/forge-forgejo/src/webhook/register.rs +++ b/crates/cli/src/forges/forgejo/webhook/register.rs @@ -1,14 +1,17 @@ -use git_next_core::git::forge::webhook::Error; // -use git_next_core::{git, server::RepoListenUrl, RegisteredWebhook, WebhookAuth, WebhookId}; +use git_next_core::{ + git::{self, forge::webhook::Error}, + server::RepoListenUrl, + RegisteredWebhook, WebhookAuth, WebhookId, +}; use kxio::net::Net; use secrecy::ExposeSecret as _; use serde_json::json; use tracing::{info, instrument, warn}; -use crate::webhook; -use crate::webhook::Hook; +use crate::forges::forgejo::webhook; +use crate::forges::forgejo::webhook::Hook; #[instrument(skip_all, fields(forge = %repo_details.forge.forge_alias(), repo = %repo_details.repo_alias))] pub async fn register( diff --git a/crates/forge-forgejo/src/webhook/unregister.rs b/crates/cli/src/forges/forgejo/webhook/unregister.rs similarity index 100% rename from crates/forge-forgejo/src/webhook/unregister.rs rename to crates/cli/src/forges/forgejo/webhook/unregister.rs diff --git a/crates/cli/src/forges/mod.rs b/crates/cli/src/forges/mod.rs new file mode 100644 index 0000000..243c51f --- /dev/null +++ b/crates/cli/src/forges/mod.rs @@ -0,0 +1,3 @@ +// +#[cfg(feature = "forgejo")] +pub mod forgejo; diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 226a348..42cab06 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -11,6 +11,8 @@ mod repo; mod root; mod server; +mod forges; + #[cfg(feature = "tui")] mod tui; diff --git a/crates/forge-forgejo/Cargo.toml b/crates/forge-forgejo/Cargo.toml deleted file mode 100644 index ca5a478..0000000 --- a/crates/forge-forgejo/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "git-next-forge-forgejo" -version = { workspace = true } -edition = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -description = "Forgejo support for git-next, the trunk-based development manager" - -[lints.clippy] -nursery = { level = "warn", priority = -1 } -pedantic = { level = "warn", priority = -1 } -unwrap_used = "warn" -expect_used = "warn" - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } - -[dependencies] -git-next-core = { workspace = true } - -# logging -tracing = { workspace = true } - -# git -async-trait = { workspace = true } - -# fs/network -kxio = { workspace = true } - -# TOML parsing -serde = { workspace = true } -serde_json = { workspace = true } - -# Secrets and Password -secrecy = { workspace = true } - -# # Actors -tokio = { workspace = true } - -[dev-dependencies] -# Testing -assert2 = { workspace = true } -rand = { workspace = true } diff --git a/crates/forge-forgejo/README.md b/crates/forge-forgejo/README.md deleted file mode 100644 index ddc70e2..0000000 --- a/crates/forge-forgejo/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# git-next - -## Trunk-based developement manager. - -`git-next` is a combined server and command-line tool that enables trunk-based -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.