Skip to content

Commit

Permalink
fix: use roots from jobs for possible npm package location
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Jan 13, 2025
1 parent 24a3aff commit 39e88a0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/lefthook/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 39e88a0

Please sign in to comment.