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

Function WriteHooks

internal/hook/hook.go:27–47  ·  view source on GitHub ↗

WriteHooks write git hooks to the given outDir

(outDir string)

Source from the content-addressed store, hash-verified

25
26// WriteHooks write git hooks to the given outDir
27func WriteHooks(outDir string) (retErr error) {
28 hookFilePath := filepath.Join(outDir, commitMsgHook)
29 // commit-msg needs to be executable
30 file, err := os.OpenFile(hookFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0700)
31 if err != nil {
32 return err
33 }
34
35 defer func() {
36 err1 := file.Close()
37 if retErr == nil && err1 != nil {
38 retErr = err1
39 }
40 }()
41
42 _, err = file.WriteString(hookMessage)
43 if err != nil {
44 return err
45 }
46 return nil
47}

Callers 1

writeHooksFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected