forked from siderolabs/kres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.go
More file actions
81 lines (61 loc) · 2.18 KB
/
Copy pathcommand.go
File metadata and controls
81 lines (61 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package lefthook
// Command represents a single named command under a hook's commands: map.
type Command struct { //nolint:govet
Run string `yaml:"run"`
Tags []string `yaml:"tags,omitempty"`
Glob string `yaml:"glob,omitempty"`
Files string `yaml:"files,omitempty"`
Skip []string `yaml:"skip,omitempty"`
Only []string `yaml:"only,omitempty"`
Interactive bool `yaml:"interactive,omitempty"`
StageFixed bool `yaml:"stage_fixed,omitempty"`
Priority int `yaml:"priority,omitempty"`
}
// WithRun sets the shell command lefthook executes for this command.
func (c *Command) WithRun(run string) *Command {
c.Run = run
return c
}
// WithTags attaches tags used for selective hook execution (lefthook --tags ...).
func (c *Command) WithTags(tags ...string) *Command {
c.Tags = tags
return c
}
// WithGlob restricts the command to files matching the given glob.
func (c *Command) WithGlob(glob string) *Command {
c.Glob = glob
return c
}
// WithFiles overrides the default file source (e.g. "git diff --name-only ...").
func (c *Command) WithFiles(files string) *Command {
c.Files = files
return c
}
// WithSkip lists git states or refs where the command should be skipped (e.g. "merge", "rebase").
func (c *Command) WithSkip(skip ...string) *Command {
c.Skip = skip
return c
}
// WithOnly is the inverse of WithSkip: command runs only in the listed states.
func (c *Command) WithOnly(only ...string) *Command {
c.Only = only
return c
}
// WithInteractive marks the command as needing a TTY (stdin/stdout passthrough).
func (c *Command) WithInteractive() *Command {
c.Interactive = true
return c
}
// WithStageFixed re-stages files modified by the command (useful for formatters).
func (c *Command) WithStageFixed() *Command {
c.StageFixed = true
return c
}
// WithPriority sets the command's run order within its hook (lower runs first).
func (c *Command) WithPriority(priority int) *Command {
c.Priority = priority
return c
}