1package hooks
2
3import (
4	"path/filepath"
5
6	"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
7)
8
9// Override allows tests to control where the hooks directory is.
10var Override string
11
12// Path returns the path where the global git hooks are located. If the
13// environment variable GITALY_TESTING_NO_GIT_HOOKS is set to "1", Path
14// will return an empty directory, which has the effect that no Git hooks
15// will run at all.
16func Path(cfg config.Cfg) string {
17	if len(Override) > 0 {
18		return Override
19	}
20
21	if config.SkipHooks() {
22		return "/var/empty"
23	}
24
25	return filepath.Join(cfg.Ruby.Dir, "git-hooks")
26}
27