(ctx context.Context)
| 14 | } |
| 15 | |
| 16 | func (cli *GitCLI) WorkTree(ctx context.Context) (string, error) { |
| 17 | if cli.workTree != "" { |
| 18 | return cli.workTree, nil |
| 19 | } |
| 20 | out, err := cli.Run(ctx, "rev-parse", "--is-inside-work-tree", "--show-toplevel") |
| 21 | out = bytes.TrimSpace(out) |
| 22 | if err != nil { |
| 23 | if string(out) == "false" { |
| 24 | return "", nil |
| 25 | } |
| 26 | return "", err |
| 27 | } |
| 28 | lines := slices.Collect(bytes.Lines(out)) |
| 29 | return string(lines[len(lines)-1]), nil |
| 30 | } |
| 31 | |
| 32 | func (cli *GitCLI) GitDir(ctx context.Context) (string, error) { |
| 33 | if cli.gitDir != "" { |
no test coverage detected