feat: get root dir from git command
This commit is contained in:
parent
ac1555a57c
commit
0d546f7824
|
@ -0,0 +1,18 @@
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RootDir() string {
|
||||||
|
cmdOut, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("exec.Command: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
rootDir := strings.TrimSpace(string(cmdOut))
|
||||||
|
return rootDir
|
||||||
|
}
|
Loading…
Reference in New Issue