MCPcopy Index your code
hub / github.com/conventionalcommit/commitlint / getRepoRootDir

Function getRepoRootDir

internal/cmd/hook.go:91–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89}
90
91func getRepoRootDir() (string, error) {
92 byteOut := &bytes.Buffer{}
93
94 cmd := exec.Command("git", "rev-parse", "--git-dir")
95 cmd.Stdout = byteOut
96 cmd.Stderr = os.Stderr
97
98 err := cmd.Run()
99 if err != nil {
100 return "", err
101 }
102
103 gitDir := filepath.Clean(byteOut.String())
104
105 // remove /.git at last
106 gitDir = filepath.Dir(gitDir)
107
108 return gitDir, nil
109}
110
111func isHookExists(err error) bool {
112 return errors.Is(err, errHooksExist)

Callers 1

getHookDirFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected