From 820fd706a24be7a58554a27e411e120cfa28d9a6 Mon Sep 17 00:00:00 2001 From: m0wer Date: Sun, 29 Mar 2026 16:45:52 +0200 Subject: feat: git worktree support Git worktrees don't have a .git directory with a parent, so we need to look for the git dir via git2's Repository::discover() and then look for the cache database there. This allows the client to work correctly when run from a worktree, and also allows the cache database to be shared between the main repo and its worktrees (since they share the same git dir and thus the same cache path). --- test_utils/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test_utils/src/lib.rs') diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 48273e8..89cbaa9 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1208,8 +1208,12 @@ where /** copied from client.rs */ async fn get_local_cache_database(git_repo_path: &Path) -> Result { - NostrLMDB::open(git_repo_path.join(".git/nostr-cache.lmdb")) - .context("failed to open or create nostr cache database at .git/nostr-cache.lmdb") + let git_dir = git2::Repository::discover(git_repo_path) + .context("failed to discover git repository")? + .commondir() + .to_path_buf(); + NostrLMDB::open(git_dir.join("nostr-cache.lmdb")) + .context("failed to open or create nostr cache database at /nostr-cache.lmdb") } /** copied from client.rs */ -- cgit v1.2.3