From b71aece8c90144baee2820e180570cf3d8a7641a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 21 Apr 2024 18:48:49 +0100 Subject: [PATCH] feat: add gitdir to RepoDetails type --- src/server/config/mod.rs | 5 +++++ src/server/gitforge/tests/common.rs | 12 +++++++++--- src/server/gitforge/tests/forgejo.rs | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/server/config/mod.rs b/src/server/config/mod.rs index 8b608b4..e5942a7 100644 --- a/src/server/config/mod.rs +++ b/src/server/config/mod.rs @@ -199,6 +199,9 @@ impl ServerRepoConfig { _ => None, } } + pub const fn gitdir(&self) -> Option<&GitDir> { + self.gitdir.as_ref() + } } #[cfg(test)] impl AsRef for ServerRepoConfig { @@ -324,6 +327,7 @@ pub struct RepoDetails { pub branch: BranchName, pub forge: ForgeDetails, pub config: Option, + pub gitdir: Option, } impl RepoDetails { pub fn new( @@ -337,6 +341,7 @@ impl RepoDetails { repo_path: RepoPath(server_repo_config.repo.clone()), config: server_repo_config.repo_config(), branch: BranchName(server_repo_config.branch.clone()), + gitdir: server_repo_config.gitdir().cloned(), forge: ForgeDetails { name: forge_name.clone(), forge_type: forge.forge_type.clone(), diff --git a/src/server/gitforge/tests/common.rs b/src/server/gitforge/tests/common.rs index 7ad0dce..e22dd3c 100644 --- a/src/server/gitforge/tests/common.rs +++ b/src/server/gitforge/tests/common.rs @@ -1,6 +1,6 @@ use crate::server::config::{ - ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, Hostname, RepoAlias, RepoBranches, - RepoConfig, RepoDetails, RepoPath, User, + ApiToken, BranchName, ForgeDetails, ForgeName, ForgeType, GitDir, Hostname, RepoAlias, + RepoBranches, RepoConfig, RepoDetails, RepoPath, User, }; pub fn forge_details(n: u32, forge_type: ForgeType) -> ForgeDetails { @@ -28,10 +28,16 @@ pub fn hostname(n: u32) -> Hostname { pub fn forge_name(n: u32) -> ForgeName { ForgeName(format!("forge-name-{}", n)) } -pub fn repo_details(n: u32, forge: ForgeDetails, config: Option) -> RepoDetails { +pub fn repo_details( + n: u32, + forge: ForgeDetails, + config: Option, + gitdir: Option, +) -> RepoDetails { RepoDetails { name: repo_alias(n), repo_path: repo_path(n), + gitdir, branch: branch_name(n), forge, config, diff --git a/src/server/gitforge/tests/forgejo.rs b/src/server/gitforge/tests/forgejo.rs index 0e1d4f8..10fea2e 100644 --- a/src/server/gitforge/tests/forgejo.rs +++ b/src/server/gitforge/tests/forgejo.rs @@ -13,6 +13,7 @@ fn test_name() { 1, common::forge_details(1, ForgeType::MockForge), Some(common::config(1)), + None, ); let forge = Forge::new_forgejo(repo_details, net); assert_eq!(forge.name(), "forgejo"); @@ -35,6 +36,7 @@ async fn test_branches_get() { 1, common::forge_details(1, ForgeType::MockForge), Some(common::config(1)), + None, ); let forge = Forge::new_forgejo(repo_details, net.clone());