(root, cwd string)
| 436 | return filepath.Dir(result.FallbackPath), nil |
| 437 | } |
| 438 | if len(result.Docs) > 0 { |
| 439 | return result.Root, nil |
| 440 | } |
| 441 | return "", errors.New("project instruction file not found") |
| 442 | } |
| 443 | |
| 444 | func findProjectRootByMarkers(start string, markers []string) string { |
| 445 | current := start |
| 446 | for { |
| 447 | for _, marker := range markers { |
| 448 | marker = strings.TrimSpace(marker) |
| 449 | if marker == "" { |
| 450 | continue |
| 451 | } |
| 452 | if _, err := os.Stat(filepath.Join(current, marker)); err == nil { |
| 453 | return current |
| 454 | } |
| 455 | } |
| 456 | parent := filepath.Dir(current) |
| 457 | if parent == current { |
| 458 | return "" |
| 459 | } |
| 460 | current = parent |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | func dirsFromRootToCWD(root, cwd string) []string { |
| 465 | root = filepath.Clean(root) |
no outgoing calls
no test coverage detected