• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

evilmartians / lefthook / 17938629224

23 Sep 2025 07:18AM UTC coverage: 72.799% (+0.2%) from 72.612%
17938629224

Pull #1139

github

web-flow
Merge be176bc82 into 116f89632
Pull Request #1139: deps: September 2025

3 of 14 new or added lines in 5 files covered. (21.43%)

1 existing line in 1 file now uncovered.

3514 of 4827 relevant lines covered (72.8%)

3.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.55
/internal/run/controller/scope.go
1
package controller
2

3
import (
4
        "slices"
5

6
        "github.com/evilmartians/lefthook/internal/config"
7
        "github.com/evilmartians/lefthook/internal/run/controller/utils"
8
)
9

10
type scope struct {
11
        follow bool
12

13
        glob         []string
14
        tags         []string
15
        excludeTags  []string // Consider removing this setting
16
        names        []string
17
        fileTypes    []string
18
        excludeFiles interface{}
19
        env          map[string]string
20
        root         string
21
        hookName     string
22
        filesCmd     string
23
        opts         Options
24
}
25

26
func newScope(hook *config.Hook, opts Options) *scope {
6✔
27
        excludeFiles := make([]interface{}, len(opts.ExcludeFiles))
6✔
28
        if len(opts.ExcludeFiles) > 0 {
9✔
29
                for i, e := range opts.ExcludeFiles {
6✔
30
                        excludeFiles[i] = e
3✔
31
                }
3✔
32
        }
33

34
        return &scope{
6✔
35
                hookName:     hook.Name,
6✔
36
                follow:       hook.Follow,
6✔
37
                filesCmd:     hook.Files,
6✔
38
                excludeTags:  hook.ExcludeTags,
6✔
39
                excludeFiles: excludeFiles,
6✔
40
                env:          make(map[string]string),
6✔
41
                opts:         opts,
6✔
42
        }
6✔
43
}
44

45
func (s *scope) extend(job *config.Job) *scope {
6✔
46
        newScope := *s
6✔
47
        newScope.glob = slices.Concat(newScope.glob, job.Glob)
6✔
48
        newScope.tags = slices.Concat(newScope.tags, job.Tags)
6✔
49
        newScope.root = utils.FirstNonBlank(job.Root, s.root)
6✔
50
        newScope.filesCmd = utils.FirstNonBlank(job.Files, s.filesCmd)
6✔
51
        newScope.fileTypes = slices.Concat(newScope.fileTypes, job.FileTypes)
6✔
52

6✔
53
        // Extend `exclude` list
6✔
54
        switch list := job.Exclude.(type) {
6✔
55
        case []interface{}:
3✔
56
                switch inherited := newScope.excludeFiles.(type) {
3✔
57
                case []interface{}:
3✔
58
                        // List of globs get appended
3✔
59
                        inherited = append(inherited, list...)
3✔
60
                        newScope.excludeFiles = inherited
3✔
UNCOV
61
                default:
×
62
                        // Regex value will be overwritten with a list of globs
×
63
                        newScope.excludeFiles = job.Exclude
×
64
                }
65
        case string:
3✔
66
                // Regex value always overwrites excludes
3✔
67
                newScope.excludeFiles = job.Exclude
3✔
68
        default:
6✔
69
                // Inherit
70
        }
71

72
        // Overwrite --jobs option for nested groups: if group name given, run all its jobs
73
        if len(s.opts.RunOnlyJobs) != 0 && job.Group != nil && slices.Contains(s.opts.RunOnlyJobs, job.Name) {
9✔
74
                newScope.opts.RunOnlyJobs = []string{}
3✔
75
        }
3✔
76

77
        if len(job.Env) > 0 {
12✔
78
                if len(newScope.env) > 0 {
9✔
79
                        env := make(map[string]string)
3✔
80
                        for key, value := range newScope.env {
6✔
81
                                env[key] = value
3✔
82
                        }
3✔
83
                        for key, value := range job.Env {
6✔
84
                                env[key] = value
3✔
85
                        }
3✔
86
                        newScope.env = env
3✔
87
                } else {
6✔
88
                        newScope.env = job.Env
6✔
89
                }
6✔
90
        }
91

92
        return &newScope
6✔
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc