Skip to content

Commit adada16

Browse files
authored
Fix multi-repo support (#69)
1 parent 8e0735c commit adada16

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

cmd/hooks.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,22 @@ func RunHook(hookName, root string) error {
247247

248248
// hookSessionStart shows project structure, starts daemon, and shows hub warnings
249249
func hookSessionStart(root string) error {
250-
// Guard: require git repo
250+
// Handle meta-repo: parent directory containing child git repos.
251+
// Check this before the git guard so that non-repo parent directories
252+
// still get multi-repo context.
253+
childRepos := findChildRepos(root)
254+
if len(childRepos) > 1 {
255+
return hookSessionStartMultiRepo(root, childRepos)
256+
}
257+
258+
// Guard: require git repo for single-repo analysis
251259
gitDir := filepath.Join(root, ".git")
252260
if _, err := os.Stat(gitDir); os.IsNotExist(err) {
253261
fmt.Println("📍 Not a git repository - skipping project context")
254262
fmt.Println(" (codemap hooks work best in git repos)")
255263
return nil
256264
}
257265

258-
// Handle meta-repo: parent git repo containing child git repos
259-
childRepos := findChildRepos(root)
260-
if len(childRepos) > 1 {
261-
return hookSessionStartMultiRepo(root, childRepos)
262-
}
263-
264266
// Check for previous session context before starting new daemon
265267
lastSessionEvents := getLastSessionEvents(root)
266268

@@ -1453,7 +1455,9 @@ func findChildRepos(root string) []string {
14531455
return nil
14541456
}
14551457

1456-
// Use git check-ignore to filter out ignored directories
1458+
// Use git check-ignore to filter out ignored directories.
1459+
// In non-git parents this silently fails and nothing is filtered,
1460+
// which is correct — .gitignore is a git concept.
14571461
args := append([]string{"check-ignore", "--"}, candidates...)
14581462
cmd := exec.Command("git", args...)
14591463
cmd.Dir = root

0 commit comments

Comments
 (0)