findGitBin finds the `git` binary in PATH that should be used by the rest of `git-sizer`. It uses `safeexec` to find the executable, because on Windows, `exec.Cmd` looks not only in PATH, but also in the current directory. This is a potential risk if the repository being scanned is hostile and non-b
()
| 13 | // being scanned is hostile and non-bare because it might possibly |
| 14 | // contain an executable file named `git`. |
| 15 | func findGitBin() (string, error) { |
| 16 | gitBin, err := safeexec.LookPath("git") |
| 17 | if err != nil { |
| 18 | return "", err |
| 19 | } |
| 20 | |
| 21 | gitBin, err = filepath.Abs(gitBin) |
| 22 | if err != nil { |
| 23 | return "", err |
| 24 | } |
| 25 | |
| 26 | return gitBin, nil |
| 27 | } |