From 9372ad649b6c438b1e4645f1dbe95c0f648bb80d Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 19 Jan 2026 14:25:27 +0000 Subject: fix: archive_read_only creates bare repos for archived announcements Combined Accept and AcceptArchive match arms in builder.rs to ensure bare repositories are created for both cases. Previously AcceptArchive had duplicate code that didn't call ensure_bare_repository(). Also includes: - Config fix: effective_git_data_path() respects explicit paths with memory backend - TestRelay: Added git_data_path() and archive config support for testing - Integration tests for archive_read_only behavior --- src/config.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 320661f..0a867e3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -562,9 +562,10 @@ impl Config { } /// Get effective git data path - /// Returns a temp directory when using memory backend, otherwise the configured path + /// Returns a temp directory when using memory backend with default path, otherwise the configured path pub fn effective_git_data_path(&self) -> String { - if self.database_backend == DatabaseBackend::Memory { + if self.database_backend == DatabaseBackend::Memory && self.git_data_path == "./data/git" { + // Only use default temp directory if git_data_path is still the default value std::env::temp_dir() .join("ngit-grasp-git") .to_string_lossy() @@ -733,15 +734,29 @@ mod tests { } #[test] - fn test_memory_backend_uses_temp_dir() { + fn test_memory_backend_uses_temp_dir_with_default_path() { + // When git_data_path is the default value, memory backend uses temp dir let config = Config { database_backend: DatabaseBackend::Memory, + git_data_path: "./data/git".to_string(), // Default value ..Config::for_testing() }; let git_path = config.effective_git_data_path(); assert!(git_path.contains("ngit-grasp-git")); } + #[test] + fn test_memory_backend_respects_custom_path() { + // When git_data_path is explicitly set, memory backend respects it + let config = Config { + database_backend: DatabaseBackend::Memory, + git_data_path: "./custom/git/path".to_string(), + ..Config::for_testing() + }; + let git_path = config.effective_git_data_path(); + assert_eq!(git_path, "./custom/git/path"); + } + #[test] fn test_lmdb_backend_uses_configured_path() { let config = Config { -- cgit v1.2.3