Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions cmd/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,22 @@ 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.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes no code: It only swaps the multiRepo check with the "git guard"

// 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")
fmt.Println(" (codemap hooks work best in git repos)")
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)

Expand Down Expand Up @@ -1453,7 +1455,9 @@ func findChildRepos(root string) []string {
return nil
}

// Use git check-ignore to filter out ignored directories
// Use git check-ignore to filter out ignored directories.
// 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
Expand Down