MCPcopy Create free account
hub / github.com/dirk/quickhook / listHooks

Function listHooks

install.go:45–72  ·  view source on GitHub ↗
(repo *repo.Repo)

Source from the content-addressed store, hash-verified

43}
44
45func listHooks(repo *repo.Repo) ([]string, error) {
46 hooksPath := path.Join(repo.Root, ".quickhook")
47
48 entries, err := ioutil.ReadDir(hooksPath)
49 if err != nil {
50 if os.IsNotExist(err) {
51 fmt.Fprintf(os.Stderr, "Missing hooks directory: %v\n", hooksPath)
52 os.Exit(66) // EX_NOINPUT
53 } else {
54 return nil, err
55 }
56 }
57
58 var hooks []string
59 for _, entry := range entries {
60 name := entry.Name()
61 // Rename the mutating hook to the regular pre-commit one.
62 if name == "pre-commit-mutating" {
63 name = "pre-commit"
64 }
65 isHook := name == "pre-commit" ||
66 name == "commit-msg"
67 if entry.IsDir() && isHook {
68 hooks = append(hooks, name)
69 }
70 }
71 return lo.Uniq(hooks), nil
72}
73
74func promptForInstallShim(stdin io.Reader, repo *repo.Repo, shimPath string) (bool, error) {
75 _, err := os.Stat(path.Join(repo.Root, shimPath))

Callers 1

installFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected