@@ -128,6 +128,12 @@ def _hook(*hook_dicts):
128128 return ret
129129
130130
131+ def _hook_from_manifest_dct (dct ):
132+ dct = validate (apply_defaults (dct , MANIFEST_HOOK_DICT ), MANIFEST_HOOK_DICT )
133+ dct = _hook (dct )
134+ return dct
135+
136+
131137class Repository (object ):
132138 def __init__ (self , repo_config , store ):
133139 self .repo_config = repo_config
@@ -226,14 +232,8 @@ def manifest(self):
226232
227233 @cached_property
228234 def hooks (self ):
229- def _from_manifest_dct (dct ):
230- dct = validate (dct , MANIFEST_HOOK_DICT )
231- dct = apply_defaults (dct , MANIFEST_HOOK_DICT )
232- dct = _hook (dct )
233- return dct
234-
235235 return tuple (
236- (hook ['id' ], _from_manifest_dct (hook ))
236+ (hook ['id' ], _hook_from_manifest_dct (hook ))
237237 for hook in self .repo_config ['hooks' ]
238238 )
239239
@@ -258,33 +258,32 @@ def manifest_hooks(self):
258258 from pre_commit .meta_hooks import check_files_matches_any
259259 from pre_commit .meta_hooks import check_useless_excludes
260260
261- # Note: the hook `entry` is passed through `shlex.split()` by the
262- # command runner, so to prevent issues with spaces and backslashes
263- # (on Windows) it must be quoted here.
261+ def _make_entry (mod ):
262+ """the hook `entry` is passed through `shlex.split()` by the
263+ command runner, so to prevent issues with spaces and backslashes
264+ (on Windows) it must be quoted here.
265+ """
266+ return '{} -m {}' .format (pipes .quote (sys .executable ), mod .__name__ )
267+
264268 meta_hooks = [
265269 {
266- 'id' : 'check-useless-excludes ' ,
267- 'name' : 'Check for useless excludes ' ,
270+ 'id' : 'check-files-matches-any ' ,
271+ 'name' : 'Check hooks match any files ' ,
268272 'files' : '.pre-commit-config.yaml' ,
269273 'language' : 'system' ,
270- 'entry' : pipes .quote (sys .executable ),
271- 'args' : ['-m' , check_useless_excludes .__name__ ],
274+ 'entry' : _make_entry (check_files_matches_any ),
272275 },
273276 {
274- 'id' : 'check-files-matches-any ' ,
275- 'name' : 'Check hooks match any files ' ,
277+ 'id' : 'check-useless-excludes ' ,
278+ 'name' : 'Check for useless excludes ' ,
276279 'files' : '.pre-commit-config.yaml' ,
277280 'language' : 'system' ,
278- 'entry' : pipes .quote (sys .executable ),
279- 'args' : ['-m' , check_files_matches_any .__name__ ],
281+ 'entry' : _make_entry (check_useless_excludes ),
280282 },
281283 ]
282284
283285 return {
284- hook ['id' ]: apply_defaults (
285- validate (hook , MANIFEST_HOOK_DICT ),
286- MANIFEST_HOOK_DICT ,
287- )
286+ hook ['id' ]: _hook_from_manifest_dct (hook )
288287 for hook in meta_hooks
289288 }
290289
0 commit comments