From f2af849d0b2ed122a11125b382017c714fbd96ad Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 23 May 2024 16:04:38 +0100 Subject: [PATCH] refactor(forge): rename gitforge crate as forge --- Cargo.toml | 4 ++-- crates/{gitforge => forge}/Cargo.toml | 2 +- .../{gitforge => forge}/src/forgejo/branch/get_all.rs | 0 crates/{gitforge => forge}/src/forgejo/branch/mod.rs | 0 .../src/forgejo/branch/validate_positions.rs | 0 crates/{gitforge => forge}/src/forgejo/file.rs | 0 crates/{gitforge => forge}/src/forgejo/mod.rs | 0 crates/{gitforge => forge}/src/github.rs | 0 crates/{gitforge => forge}/src/lib.rs | 0 crates/{gitforge => forge}/src/mock_forge.rs | 0 .../src/tests/data-forgejo-branches-get.json | 0 crates/{gitforge => forge}/src/tests/forgejo.rs | 0 crates/{gitforge => forge}/src/tests/github.rs | 0 crates/{gitforge => forge}/src/tests/mod.rs | 0 crates/repo-actor/Cargo.toml | 2 +- crates/repo-actor/src/branch.rs | 7 ++++--- crates/repo-actor/src/config.rs | 5 +++-- crates/repo-actor/src/lib.rs | 10 +++++----- crates/repo-actor/src/load.rs | 11 +++++------ crates/repo-actor/src/status.rs | 3 ++- crates/server/Cargo.toml | 2 +- 21 files changed, 24 insertions(+), 22 deletions(-) rename crates/{gitforge => forge}/Cargo.toml (97%) rename crates/{gitforge => forge}/src/forgejo/branch/get_all.rs (100%) rename crates/{gitforge => forge}/src/forgejo/branch/mod.rs (100%) rename crates/{gitforge => forge}/src/forgejo/branch/validate_positions.rs (100%) rename crates/{gitforge => forge}/src/forgejo/file.rs (100%) rename crates/{gitforge => forge}/src/forgejo/mod.rs (100%) rename crates/{gitforge => forge}/src/github.rs (100%) rename crates/{gitforge => forge}/src/lib.rs (100%) rename crates/{gitforge => forge}/src/mock_forge.rs (100%) rename crates/{gitforge => forge}/src/tests/data-forgejo-branches-get.json (100%) rename crates/{gitforge => forge}/src/tests/forgejo.rs (100%) rename crates/{gitforge => forge}/src/tests/github.rs (100%) rename crates/{gitforge => forge}/src/tests/mod.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index e61802cd..ebfc5721 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "crates/server", "crates/config", "crates/git", - "crates/gitforge", + "crates/forge", "crates/repo-actor", ] @@ -23,7 +23,7 @@ expect_used = "warn" git-next-server = { path = "crates/server" } git-next-config = { path = "crates/config" } git-next-git = { path = "crates/git" } -git-next-gitforge = { path = "crates/gitforge" } +git-next-forge = { path = "crates/forge" } git-next-repo-actor = { path = "crates/repo-actor" } # CLI parsing diff --git a/crates/gitforge/Cargo.toml b/crates/forge/Cargo.toml similarity index 97% rename from crates/gitforge/Cargo.toml rename to crates/forge/Cargo.toml index 941c7681..c243615e 100644 --- a/crates/gitforge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "git-next-gitforge" +name = "git-next-forge" version = { workspace = true } edition = { workspace = true } diff --git a/crates/gitforge/src/forgejo/branch/get_all.rs b/crates/forge/src/forgejo/branch/get_all.rs similarity index 100% rename from crates/gitforge/src/forgejo/branch/get_all.rs rename to crates/forge/src/forgejo/branch/get_all.rs diff --git a/crates/gitforge/src/forgejo/branch/mod.rs b/crates/forge/src/forgejo/branch/mod.rs similarity index 100% rename from crates/gitforge/src/forgejo/branch/mod.rs rename to crates/forge/src/forgejo/branch/mod.rs diff --git a/crates/gitforge/src/forgejo/branch/validate_positions.rs b/crates/forge/src/forgejo/branch/validate_positions.rs similarity index 100% rename from crates/gitforge/src/forgejo/branch/validate_positions.rs rename to crates/forge/src/forgejo/branch/validate_positions.rs diff --git a/crates/gitforge/src/forgejo/file.rs b/crates/forge/src/forgejo/file.rs similarity index 100% rename from crates/gitforge/src/forgejo/file.rs rename to crates/forge/src/forgejo/file.rs diff --git a/crates/gitforge/src/forgejo/mod.rs b/crates/forge/src/forgejo/mod.rs similarity index 100% rename from crates/gitforge/src/forgejo/mod.rs rename to crates/forge/src/forgejo/mod.rs diff --git a/crates/gitforge/src/github.rs b/crates/forge/src/github.rs similarity index 100% rename from crates/gitforge/src/github.rs rename to crates/forge/src/github.rs diff --git a/crates/gitforge/src/lib.rs b/crates/forge/src/lib.rs similarity index 100% rename from crates/gitforge/src/lib.rs rename to crates/forge/src/lib.rs diff --git a/crates/gitforge/src/mock_forge.rs b/crates/forge/src/mock_forge.rs similarity index 100% rename from crates/gitforge/src/mock_forge.rs rename to crates/forge/src/mock_forge.rs diff --git a/crates/gitforge/src/tests/data-forgejo-branches-get.json b/crates/forge/src/tests/data-forgejo-branches-get.json similarity index 100% rename from crates/gitforge/src/tests/data-forgejo-branches-get.json rename to crates/forge/src/tests/data-forgejo-branches-get.json diff --git a/crates/gitforge/src/tests/forgejo.rs b/crates/forge/src/tests/forgejo.rs similarity index 100% rename from crates/gitforge/src/tests/forgejo.rs rename to crates/forge/src/tests/forgejo.rs diff --git a/crates/gitforge/src/tests/github.rs b/crates/forge/src/tests/github.rs similarity index 100% rename from crates/gitforge/src/tests/github.rs rename to crates/forge/src/tests/github.rs diff --git a/crates/gitforge/src/tests/mod.rs b/crates/forge/src/tests/mod.rs similarity index 100% rename from crates/gitforge/src/tests/mod.rs rename to crates/forge/src/tests/mod.rs diff --git a/crates/repo-actor/Cargo.toml b/crates/repo-actor/Cargo.toml index 304dcbfa..17384818 100644 --- a/crates/repo-actor/Cargo.toml +++ b/crates/repo-actor/Cargo.toml @@ -11,7 +11,7 @@ github = [] [dependencies] git-next-config = { workspace = true } git-next-git = { workspace = true } -git-next-gitforge = { workspace = true } +git-next-forge = { workspace = true } # logging console-subscriber = { workspace = true } diff --git a/crates/repo-actor/src/branch.rs b/crates/repo-actor/src/branch.rs index d63d0114..21f80ab8 100644 --- a/crates/repo-actor/src/branch.rs +++ b/crates/repo-actor/src/branch.rs @@ -3,10 +3,11 @@ use std::time::Duration; use actix::prelude::*; use git_next_config::RepoConfig; +use git_next_forge as forge; use git_next_git as git; use tracing::{info, warn}; -use crate::{gitforge, MessageToken, ValidateRepo}; +use crate::{MessageToken, ValidateRepo}; // advance next to the next commit towards the head of the dev branch #[tracing::instrument(fields(next), skip_all)] @@ -14,7 +15,7 @@ pub async fn advance_next( next: git::Commit, dev_commit_history: Vec, repo_config: RepoConfig, - forge: gitforge::Forge, + forge: forge::Forge, repository: git::OpenRepository, addr: Addr, message_token: MessageToken, @@ -78,7 +79,7 @@ pub fn find_next_commit_on_dev( pub async fn advance_main( next: git::Commit, repo_config: &RepoConfig, - forge: &gitforge::Forge, + forge: &forge::Forge, repository: &git::OpenRepository, ) { info!("Advancing main to next"); diff --git a/crates/repo-actor/src/config.rs b/crates/repo-actor/src/config.rs index 5017a506..769abfc7 100644 --- a/crates/repo-actor/src/config.rs +++ b/crates/repo-actor/src/config.rs @@ -1,14 +1,15 @@ use actix::prelude::*; +use git_next_forge as forge; use git_next_git::RepoDetails; use tracing::{error, info}; -use crate::{gitforge, load}; +use crate::load; use super::{LoadedConfig, RepoActor}; /// Loads the [RepoConfig] from the `.git-next.toml` file in the repository #[tracing::instrument(skip_all, fields(branch = %repo_details.branch))] -pub async fn load(repo_details: RepoDetails, addr: Addr, forge: gitforge::Forge) { +pub async fn load(repo_details: RepoDetails, addr: Addr, forge: forge::Forge) { info!("Loading .git-next.toml from repo"); let repo_config = match load::load(&repo_details, &forge).await { Ok(repo_config) => repo_config, diff --git a/crates/repo-actor/src/lib.rs b/crates/repo-actor/src/lib.rs index 22bce3db..ec5eb9aa 100644 --- a/crates/repo-actor/src/lib.rs +++ b/crates/repo-actor/src/lib.rs @@ -12,8 +12,8 @@ use std::time::Duration; use actix::prelude::*; use git::OpenRepository; use git_next_config::{server::Webhook, ForgeType, RepoConfig, RepoConfigSource}; +use git_next_forge as forge; use git_next_git::{self as git, Generation, RepoDetails}; -use git_next_gitforge::{self as gitforge, validation}; use kxio::network::Network; use tracing::{debug, info, warn, Instrument}; @@ -37,7 +37,7 @@ pub struct RepoActor { last_dev_commit: Option, repository: Option, net: Network, - forge: gitforge::Forge, + forge: forge::Forge, } impl RepoActor { pub fn new( @@ -49,8 +49,8 @@ impl RepoActor { ) -> Self { let forge = match details.forge.forge_type() { #[cfg(feature = "forgejo")] - ForgeType::ForgeJo => gitforge::Forge::new_forgejo(details.clone(), net.clone(), repo), - ForgeType::MockForge => gitforge::Forge::new_mock(), + ForgeType::ForgeJo => forge::Forge::new_forgejo(details.clone(), net.clone(), repo), + ForgeType::MockForge => forge::Forge::new_mock(), }; debug!(?forge, "new"); Self { @@ -191,7 +191,7 @@ impl Handler for RepoActor { .branches_validate_positions(repository, repo_config) .await { - Ok(validation::Positions { + Ok(forge::validation::Positions { main, next, dev, diff --git a/crates/repo-actor/src/load.rs b/crates/repo-actor/src/load.rs index a27c3bc6..df92eb28 100644 --- a/crates/repo-actor/src/load.rs +++ b/crates/repo-actor/src/load.rs @@ -1,10 +1,9 @@ use git_next_config::{self as config, BranchName, RepoConfig}; +use git_next_forge as forge; use git_next_git::RepoDetails; use tracing::error; -use crate::gitforge; - -pub async fn load(details: &RepoDetails, forge: &gitforge::Forge) -> Result { +pub async fn load(details: &RepoDetails, forge: &forge::Forge) -> Result { let contents = forge .file_contents_get(&details.branch, ".git-next.toml") .await?; @@ -15,14 +14,14 @@ pub async fn load(details: &RepoDetails, forge: &gitforge::Forge) -> Result Result { +pub async fn validate(config: RepoConfig, forge: &forge::Forge) -> Result { let branches = forge.branches_get_all().await.map_err(|e| { error!(?e, "Failed to list branches"); Error::Forge(e) diff --git a/crates/repo-actor/src/status.rs b/crates/repo-actor/src/status.rs index 95e00b4d..a5b06afd 100644 --- a/crates/repo-actor/src/status.rs +++ b/crates/repo-actor/src/status.rs @@ -1,6 +1,7 @@ // use actix::prelude::*; +use git_next_forge as forge; use git_next_git as git; use tracing::{info, warn}; @@ -11,7 +12,7 @@ use super::AdvanceMainTo; pub async fn check_next( next: git::Commit, addr: Addr, - forge: git_next_gitforge::Forge, + forge: forge::Forge, message_token: MessageToken, ) { // get the status - pass, fail, pending (all others map to fail, e.g. error) diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index a6baf18d..4b6049f0 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -11,7 +11,7 @@ github = [] [dependencies] git-next-config = { workspace = true } git-next-git = { workspace = true } -git-next-gitforge = { workspace = true } +git-next-forge = { workspace = true } git-next-repo-actor = { workspace = true } # logging