MCPcopy
hub / github.com/github/git-sizer / findGitBin

Function findGitBin

git/git_bin.go:15–27  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

13// being scanned is hostile and non-bare because it might possibly
14// contain an executable file named `git`.
15func 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}

Callers 1

NewRepositoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected