From 2bec43c07c8e2af67dca5ff09721cd15b8778168 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Tue, 7 Apr 2026 00:25:25 +0200 Subject: [PATCH 1/2] Fix multi-repo support The tool would bail out too early so far. It would detect that there is no git directory and then bail instead of checking for subdirectories with git directories --- cmd/hooks.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cmd/hooks.go b/cmd/hooks.go index c834cd2..45f29fe 100644 --- a/cmd/hooks.go +++ b/cmd/hooks.go @@ -247,7 +247,15 @@ func RunHook(hookName, root string) error { // hookSessionStart shows project structure, starts daemon, and shows hub warnings func hookSessionStart(root string) error { - // Guard: require git repo + // Handle meta-repo: parent directory containing child git repos. + // Check this before the git guard so that non-repo parent directories + // still get multi-repo context. + childRepos := findChildRepos(root) + if len(childRepos) > 1 { + return hookSessionStartMultiRepo(root, childRepos) + } + + // Guard: require git repo for single-repo analysis gitDir := filepath.Join(root, ".git") if _, err := os.Stat(gitDir); os.IsNotExist(err) { fmt.Println("📍 Not a git repository - skipping project context") @@ -255,12 +263,6 @@ func hookSessionStart(root string) error { return nil } - // Handle meta-repo: parent git repo containing child git repos - childRepos := findChildRepos(root) - if len(childRepos) > 1 { - return hookSessionStartMultiRepo(root, childRepos) - } - // Check for previous session context before starting new daemon lastSessionEvents := getLastSessionEvents(root) @@ -1453,15 +1455,18 @@ func findChildRepos(root string) []string { return nil } - // Use git check-ignore to filter out ignored directories - args := append([]string{"check-ignore", "--"}, candidates...) - cmd := exec.Command("git", args...) - cmd.Dir = root - out, _ := cmd.Output() + // Use git check-ignore to filter out ignored directories. + // Skip filtering if the root is not a git repo (e.g. a parent directory). ignored := make(map[string]bool) - for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") { - if line != "" { - ignored[line] = true + if _, err := os.Stat(filepath.Join(root, ".git")); err == nil { + args := append([]string{"check-ignore", "--"}, candidates...) + cmd := exec.Command("git", args...) + cmd.Dir = root + out, _ := cmd.Output() + for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") { + if line != "" { + ignored[line] = true + } } } From fb075b70cb78b06d449174e7741fffe827473565 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Thu, 9 Apr 2026 20:51:17 +0200 Subject: [PATCH 2/2] Revert change to check for .git --- cmd/hooks.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/hooks.go b/cmd/hooks.go index 45f29fe..f835111 100644 --- a/cmd/hooks.go +++ b/cmd/hooks.go @@ -1456,17 +1456,16 @@ func findChildRepos(root string) []string { } // Use git check-ignore to filter out ignored directories. - // Skip filtering if the root is not a git repo (e.g. a parent directory). + // In non-git parents this silently fails and nothing is filtered, + // which is correct — .gitignore is a git concept. + args := append([]string{"check-ignore", "--"}, candidates...) + cmd := exec.Command("git", args...) + cmd.Dir = root + out, _ := cmd.Output() ignored := make(map[string]bool) - if _, err := os.Stat(filepath.Join(root, ".git")); err == nil { - args := append([]string{"check-ignore", "--"}, candidates...) - cmd := exec.Command("git", args...) - cmd.Dir = root - out, _ := cmd.Output() - for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") { - if line != "" { - ignored[line] = true - } + for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") { + if line != "" { + ignored[line] = true } }