MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / printDebug

Function printDebug

internal/cmd/debug.go:13–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func printDebug() error {
14 w := &strings.Builder{}
15 w.WriteString("Commitlint Version: ")
16 w.WriteString(internal.FullVersion())
17 w.WriteByte('\n')
18
19 gitVer, err := getGitVersion()
20 if err != nil {
21 return err
22 }
23
24 localConf, err := getGitHookConfig(false)
25 if err != nil {
26 return err
27 }
28
29 globalConf, err := getGitHookConfig(true)
30 if err != nil {
31 return err
32 }
33
34 confFile, confType, err := internal.LookupConfigPath()
35 if err != nil {
36 return err
37 }
38
39 w.WriteString("Git Version: ")
40 w.WriteString(gitVer)
41 w.WriteByte('\n')
42
43 w.WriteString("Local Hook: ")
44 w.WriteString(localConf)
45 w.WriteByte('\n')
46
47 w.WriteString("Global Hook: ")
48 w.WriteString(globalConf)
49
50 switch confType {
51 case internal.DefaultConfig:
52 fmt.Fprintf(w, "\nConfig: Default")
53 case internal.FileConfig:
54 fmt.Fprintf(w, "\nConfig: %s - %s", confType, confFile)
55 case internal.EnvConfig:
56 fmt.Fprintf(w, "\nConfig: %s:%s - %s", confType, internal.CommitlintConfigEnv, confFile)
57 }
58
59 fmt.Println(w.String())
60 return nil
61}
62
63func getGitVersion() (string, error) {
64 b := &bytes.Buffer{}

Callers 1

newDebugCmdFunction · 0.85

Calls 5

FullVersionFunction · 0.92
LookupConfigPathFunction · 0.92
getGitVersionFunction · 0.85
getGitHookConfigFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected