From 834f17621f824915b7e408109437394b62846650 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Mon, 13 Jan 2025 13:51:16 +0300 Subject: [PATCH] fix: use roots from jobs for possible npm package location (#924) --- internal/lefthook/install.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/lefthook/install.go b/internal/lefthook/install.go index 3461567f..566bdfbb 100644 --- a/internal/lefthook/install.go +++ b/internal/lefthook/install.go @@ -205,6 +205,8 @@ func (l *Lefthook) createHooksIfNeeded(cfg *config.Config, checkHashSum, force b } } } + + collectAllJobRoots(rootsMap, hook.Jobs) } roots := make([]string, 0, len(rootsMap)) for root := range rootsMap { @@ -252,6 +254,21 @@ func (l *Lefthook) createHooksIfNeeded(cfg *config.Config, checkHashSum, force b return nil } +func collectAllJobRoots(roots map[string]struct{}, jobs []*config.Job) { + for _, job := range jobs { + if len(job.Root) > 0 { + root := strings.Trim(job.Root, "/") + if _, ok := roots[root]; !ok { + roots[root] = struct{}{} + } + } + + if job.Group != nil { + collectAllJobRoots(roots, job.Group.Jobs) + } + } +} + func (l *Lefthook) hooksSynchronized(cfg *config.Config) bool { // Check checksum in a checksum file file, err := l.Fs.Open(l.checksumFilePath())