mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add checking for manifest files regex.
This commit is contained in:
parent
bd1afceeaf
commit
bf912cfebb
4 changed files with 45 additions and 19 deletions
|
|
@ -2,6 +2,7 @@ import sys
|
|||
|
||||
from pre_commit.clientlib.validate_base import get_run_function
|
||||
from pre_commit.clientlib.validate_base import get_validator
|
||||
from pre_commit.clientlib.validate_base import is_regex_valid
|
||||
from pre_commit.languages.all import all_languages
|
||||
|
||||
|
||||
|
|
@ -29,18 +30,31 @@ MANIFEST_JSON_SCHEMA = {
|
|||
}
|
||||
|
||||
|
||||
def validate_languages(hook_config):
|
||||
if hook_config['language'] not in all_languages:
|
||||
raise InvalidManifestError(
|
||||
'Expected language {0} for {1} to be one of {2!r}'.format(
|
||||
hook_config['id'],
|
||||
hook_config['language'],
|
||||
all_languages,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def validate_files(hook_config):
|
||||
if not is_regex_valid(hook_config['files']):
|
||||
raise InvalidManifestError(
|
||||
'Invalid files regex at {0}: {1}'.format(
|
||||
hook_config['id'],
|
||||
hook_config['files'],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def additional_manifest_check(obj):
|
||||
for hook_config in obj:
|
||||
language = hook_config['language']
|
||||
|
||||
if language not in all_languages:
|
||||
raise InvalidManifestError(
|
||||
'Expected language {0} for {1} to be one of {2!r}'.format(
|
||||
hook_config['id'],
|
||||
hook_config['language'],
|
||||
all_languages,
|
||||
)
|
||||
)
|
||||
validate_languages(hook_config)
|
||||
validate_files(hook_config)
|
||||
|
||||
|
||||
load_manifest = get_validator(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue