(directory string, filenames []string, maxBytes int)
| 313 | func runGitCommand(cwd string, timeout time.Duration, args ...string) (string, bool) { |
| 314 | ctx, cancel := context.WithTimeout(context.Background(), timeout) |
| 315 | defer cancel() |
| 316 | cmd := exec.CommandContext(ctx, "git", args...) |
| 317 | cmd.Dir = cwd |
| 318 | out, err := cmd.Output() |
| 319 | if err != nil { |
| 320 | return "", false |
| 321 | } |
| 322 | return string(out), true |
| 323 | } |
| 324 | |
| 325 | func readProjectInstructionFile(directory string) (string, error) { |
| 326 | doc, err := readProjectInstructionFileWithOptions(directory, projectInstructionFilenames, 0) |
| 327 | if err != nil { |
| 328 | return "", err |
| 329 | } |
| 330 | return doc.Content, nil |
| 331 | } |
| 332 | |
| 333 | func readProjectInstructionFileWithOptions(directory string, filenames []string, maxBytes int) (ProjectDoc, error) { |
| 334 | if len(filenames) == 0 { |
| 335 | filenames = projectInstructionFilenames |
| 336 | } |
| 337 | for _, filename := range filenames { |
| 338 | instructionFilePath := filepath.Join(directory, filename) |
| 339 | info, err := os.Stat(instructionFilePath) |
| 340 | if err != nil || info.IsDir() { |
| 341 | continue |
no test coverage detected