Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Prepare GO cache (pull_request) Successful in 4m57s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 13m22s
CI Workflow / CI run build and linting (pull_request) Successful in 17m32s
CI Workflow / Code coverage report (pull_request) Successful in 12s
CI Workflow / CI run tests (pull_request) Failing after 19m11s
20 lines
377 B
Go
20 lines
377 B
Go
package tools
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func GetGitRoot() (string, error) {
|
|
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
|
out, err := cmd.Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
lines := strings.Split(string(out), "\n")
|
|
if lines[0] == "" {
|
|
return "", fmt.Errorf("unable to determine root directory from git")
|
|
}
|
|
return lines[0], nil
|
|
}
|