(cwd string)
| 20 | } |
| 21 | |
| 22 | type WorktreeManager struct{} |
| 23 | |
| 24 | func FindGitRoot(cwd string) string { |
| 25 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 26 | defer cancel() |
| 27 | cmd := exec.CommandContext(ctx, "git", "rev-parse", "--show-toplevel") |
| 28 | cmd.Dir = cwd |
| 29 | out, err := cmd.Output() |
| 30 | if err != nil { |
| 31 | return "" |
| 32 | } |
| 33 | return filepath.Clean(stringTrimSpace(out)) |
| 34 | } |
| 35 |