mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 18:41:46 +04:00
Check unsupported TOP_LEVEL_KEYS
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
This commit is contained in:
parent
da00fa98f9
commit
04c581dedc
1 changed files with 16 additions and 0 deletions
|
|
@ -162,6 +162,7 @@ def _non_cloned_repository_hooks(repo_config, store, root_config):
|
||||||
|
|
||||||
|
|
||||||
def _cloned_repository_hooks(repo_config, store, root_config):
|
def _cloned_repository_hooks(repo_config, store, root_config):
|
||||||
|
_check_extra_top_level_keys(repo_config)
|
||||||
repo, rev = repo_config['repo'], repo_config['rev']
|
repo, rev = repo_config['repo'], repo_config['rev']
|
||||||
manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)
|
manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)
|
||||||
by_id = {hook['id']: hook for hook in load_manifest(manifest_path)}
|
by_id = {hook['id']: hook for hook in load_manifest(manifest_path)}
|
||||||
|
|
@ -190,6 +191,21 @@ def _cloned_repository_hooks(repo_config, store, root_config):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
_TOP_LEVEL_KEYS = ('repo', 'rev', 'hooks')
|
||||||
|
|
||||||
|
|
||||||
|
def _check_extra_top_level_keys(repo_config):
|
||||||
|
extra_top_level_keys = set(dict(repo_config).keys()) - set(_TOP_LEVEL_KEYS)
|
||||||
|
if extra_top_level_keys:
|
||||||
|
logger.warning(
|
||||||
|
'Unexpected top level keys present: {}, only supported'
|
||||||
|
'top level keys: {}'.format(
|
||||||
|
extra_top_level_keys,
|
||||||
|
_TOP_LEVEL_KEYS,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _repository_hooks(repo_config, store, root_config):
|
def _repository_hooks(repo_config, store, root_config):
|
||||||
if repo_config['repo'] in {LOCAL, META}:
|
if repo_config['repo'] in {LOCAL, META}:
|
||||||
return _non_cloned_repository_hooks(repo_config, store, root_config)
|
return _non_cloned_repository_hooks(repo_config, store, root_config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue