File tree 3 files changed +19
-6
lines changed
3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 5
5
"fmt"
6
6
"os"
7
7
"path/filepath"
8
+ "slices"
8
9
"strings"
9
10
"time"
10
11
@@ -97,8 +98,12 @@ Run 'lefthook install' manually.`,
97
98
// Find the hook
98
99
hook , ok := cfg .Hooks [hookName ]
99
100
if ! ok {
100
- log .Debugf ("[lefthook] skip: Hook %s doesn't exist in the config" , hookName )
101
- return nil
101
+ if slices .Contains (config .AvailableHooks [:], hookName ) {
102
+ log .Debugf ("[lefthook] skip: Hook %s doesn't exist in the config" , hookName )
103
+ return nil
104
+ }
105
+
106
+ return fmt .Errorf ("Hook %s doesn't exist in the config" , hookName )
102
107
}
103
108
if err := hook .Validate (); err != nil {
104
109
return err
Original file line number Diff line number Diff line change @@ -47,31 +47,31 @@ func TestRun(t *testing.T) {
47
47
}{
48
48
{
49
49
name : "Skip case" ,
50
- hook : "any-hook " ,
50
+ hook : "pre-commit " ,
51
51
envs : map [string ]string {
52
52
"LEFTHOOK" : "0" ,
53
53
},
54
54
error : false ,
55
55
},
56
56
{
57
57
name : "Skip case" ,
58
- hook : "any-hook " ,
58
+ hook : "pre-commit " ,
59
59
envs : map [string ]string {
60
60
"LEFTHOOK" : "false" ,
61
61
},
62
62
error : false ,
63
63
},
64
64
{
65
65
name : "Invalid version" ,
66
- hook : "any-hook " ,
66
+ hook : "pre-commit " ,
67
67
config : `
68
68
min_version: 23.0.1
69
69
` ,
70
70
error : true ,
71
71
},
72
72
{
73
73
name : "Valid version, no hook" ,
74
- hook : "any-hook " ,
74
+ hook : "pre-commit " ,
75
75
config : `
76
76
min_version: 0.7.9
77
77
` ,
Original file line number Diff line number Diff line change
1
+ exec git init
2
+ exec lefthook run pre-commit
3
+ ! stdout 'Error.*'
4
+ ! exec lefthook run no-a-hook
5
+ stdout 'Error.*'
6
+
7
+ -- lefthook.yml --
8
+ # empty
You can’t perform that action at this time.
0 commit comments