HookDir returns the location of the hooks owned by this repository. If the core.hooksPath configuration variable is supported, we prefer that and expand paths appropriately.
()
| 347 | // core.hooksPath configuration variable is supported, we prefer that and expand |
| 348 | // paths appropriately. |
| 349 | func (c *Configuration) HookDir() (string, error) { |
| 350 | if git.IsGitVersionAtLeast("2.9.0") { |
| 351 | hp, ok := c.Git.Get("core.hooksPath") |
| 352 | if ok { |
| 353 | path, err := tools.ExpandPath(hp, false) |
| 354 | if err != nil { |
| 355 | return "", err |
| 356 | } |
| 357 | if filepath.IsAbs(path) { |
| 358 | return path, nil |
| 359 | } |
| 360 | return filepath.Join(c.LocalWorkingDir(), path), nil |
| 361 | } |
| 362 | } |
| 363 | return filepath.Join(c.LocalGitStorageDir(), "hooks"), nil |
| 364 | } |
| 365 | |
| 366 | func (c *Configuration) InRepo() bool { |
| 367 | return len(c.LocalGitDir()) > 0 |
no test coverage detected