mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Make hooks specify files. Optionally allow config to override manifest.
This commit is contained in:
@@ -32,7 +32,7 @@ CONFIG_JSON_SCHEMA = {
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
},
|
||||
'required': ['id', 'files'],
|
||||
'required': ['id'],
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -55,7 +55,7 @@ def try_regex(repo, hook, value, field_name):
|
||||
def validate_config_extra(config):
|
||||
for repo in config:
|
||||
for hook in repo['hooks']:
|
||||
try_regex(repo, hook['id'], hook['files'], 'files')
|
||||
try_regex(repo, hook['id'], hook.get('files', ''), 'files')
|
||||
try_regex(repo, hook['id'], hook['exclude'], 'exclude')
|
||||
|
||||
|
||||
|
||||
@@ -21,9 +21,10 @@ MANIFEST_JSON_SCHEMA = {
|
||||
'entry': {'type': 'string'},
|
||||
'language': {'type': 'string'},
|
||||
'language_version': {'type': 'string', 'default': 'default'},
|
||||
'files': {'type': 'string'},
|
||||
'expected_return_value': {'type': 'number', 'default': 0},
|
||||
},
|
||||
'required': ['id', 'name', 'entry', 'language'],
|
||||
'required': ['id', 'name', 'entry', 'language', 'files'],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class Repository(object):
|
||||
def hooks(self):
|
||||
# TODO: merging in manifest dicts is a smell imo
|
||||
return OrderedDict(
|
||||
(hook['id'], dict(hook, **self.manifest.hooks[hook['id']]))
|
||||
(hook['id'], dict(self.manifest.hooks[hook['id']], **hook))
|
||||
for hook in self.repo_config['hooks']
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user