diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-19 14:25:27 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-19 15:04:00 +0000 |
| commit | 9372ad649b6c438b1e4645f1dbe95c0f648bb80d (patch) | |
| tree | a2f95431711bde64713aeb72f3a7dcc65ffe58cc /src/config.rs | |
| parent | 16833501a1004a5a661a729e4fd2dbcbeaecd1d5 (diff) | |
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
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 21 |
1 files changed, 18 insertions, 3 deletions
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 { | |||
| 562 | } | 562 | } |
| 563 | 563 | ||
| 564 | /// Get effective git data path | 564 | /// Get effective git data path |
| 565 | /// Returns a temp directory when using memory backend, otherwise the configured path | 565 | /// Returns a temp directory when using memory backend with default path, otherwise the configured path |
| 566 | pub fn effective_git_data_path(&self) -> String { | 566 | pub fn effective_git_data_path(&self) -> String { |
| 567 | if self.database_backend == DatabaseBackend::Memory { | 567 | if self.database_backend == DatabaseBackend::Memory && self.git_data_path == "./data/git" { |
| 568 | // Only use default temp directory if git_data_path is still the default value | ||
| 568 | std::env::temp_dir() | 569 | std::env::temp_dir() |
| 569 | .join("ngit-grasp-git") | 570 | .join("ngit-grasp-git") |
| 570 | .to_string_lossy() | 571 | .to_string_lossy() |
| @@ -733,9 +734,11 @@ mod tests { | |||
| 733 | } | 734 | } |
| 734 | 735 | ||
| 735 | #[test] | 736 | #[test] |
| 736 | fn test_memory_backend_uses_temp_dir() { | 737 | fn test_memory_backend_uses_temp_dir_with_default_path() { |
| 738 | // When git_data_path is the default value, memory backend uses temp dir | ||
| 737 | let config = Config { | 739 | let config = Config { |
| 738 | database_backend: DatabaseBackend::Memory, | 740 | database_backend: DatabaseBackend::Memory, |
| 741 | git_data_path: "./data/git".to_string(), // Default value | ||
| 739 | ..Config::for_testing() | 742 | ..Config::for_testing() |
| 740 | }; | 743 | }; |
| 741 | let git_path = config.effective_git_data_path(); | 744 | let git_path = config.effective_git_data_path(); |
| @@ -743,6 +746,18 @@ mod tests { | |||
| 743 | } | 746 | } |
| 744 | 747 | ||
| 745 | #[test] | 748 | #[test] |
| 749 | fn test_memory_backend_respects_custom_path() { | ||
| 750 | // When git_data_path is explicitly set, memory backend respects it | ||
| 751 | let config = Config { | ||
| 752 | database_backend: DatabaseBackend::Memory, | ||
| 753 | git_data_path: "./custom/git/path".to_string(), | ||
| 754 | ..Config::for_testing() | ||
| 755 | }; | ||
| 756 | let git_path = config.effective_git_data_path(); | ||
| 757 | assert_eq!(git_path, "./custom/git/path"); | ||
| 758 | } | ||
| 759 | |||
| 760 | #[test] | ||
| 746 | fn test_lmdb_backend_uses_configured_path() { | 761 | fn test_lmdb_backend_uses_configured_path() { |
| 747 | let config = Config { | 762 | let config = Config { |
| 748 | database_backend: DatabaseBackend::Lmdb, | 763 | database_backend: DatabaseBackend::Lmdb, |