mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Default local / meta through cfgv
This commit is contained in:
parent
46ae88c1f0
commit
fc84567923
11 changed files with 109 additions and 112 deletions
|
|
@ -5,12 +5,14 @@ import os.path
|
|||
import re
|
||||
import shutil
|
||||
|
||||
import cfgv
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import five
|
||||
from pre_commit import parse_shebang
|
||||
from pre_commit.clientlib import CONFIG_REPO_DICT
|
||||
from pre_commit.clientlib import load_manifest
|
||||
from pre_commit.languages import golang
|
||||
from pre_commit.languages import helpers
|
||||
|
|
@ -42,6 +44,8 @@ def _norm_out(b):
|
|||
|
||||
|
||||
def _get_hook(config, store, hook_id):
|
||||
config = cfgv.validate(config, CONFIG_REPO_DICT)
|
||||
config = cfgv.apply_defaults(config, CONFIG_REPO_DICT)
|
||||
hooks = repository_hooks(config, store)
|
||||
install_hook_envs(hooks, store)
|
||||
hook, = [hook for hook in hooks if hook.id == hook_id]
|
||||
|
|
@ -711,17 +715,6 @@ def test_hook_id_not_present(tempdir_factory, store, fake_log_handler):
|
|||
)
|
||||
|
||||
|
||||
def test_meta_hook_not_present(store, fake_log_handler):
|
||||
config = {'repo': 'meta', 'hooks': [{'id': 'i-dont-exist'}]}
|
||||
with pytest.raises(SystemExit):
|
||||
_get_hook(config, store, 'i-dont-exist')
|
||||
assert fake_log_handler.handle.call_args[0][0].msg == (
|
||||
'`i-dont-exist` is not a valid meta hook. '
|
||||
'Typo? Perhaps it is introduced in a newer version? '
|
||||
'Often `pip install --upgrade pre-commit` fixes this.'
|
||||
)
|
||||
|
||||
|
||||
def test_too_new_version(tempdir_factory, store, fake_log_handler):
|
||||
path = make_repo(tempdir_factory, 'script_hooks_repo')
|
||||
with modify_manifest(path) as manifest:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue