mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
extended warning if globs are used instead of regex to top level
This commit is contained in:
parent
7432acc215
commit
b1a9209f9f
2 changed files with 34 additions and 4 deletions
|
|
@ -244,7 +244,7 @@ def test_warn_mutable_rev_conditional():
|
|||
cfgv.validate(config_obj, CONFIG_REPO_DICT)
|
||||
|
||||
|
||||
def test_validate_optional_sensible_regex(caplog):
|
||||
def test_validate_optional_sensible_regex_at_hook_level(caplog):
|
||||
config_obj = {
|
||||
'id': 'flake8',
|
||||
'files': 'dir/*.py',
|
||||
|
|
@ -261,6 +261,23 @@ def test_validate_optional_sensible_regex(caplog):
|
|||
]
|
||||
|
||||
|
||||
def test_validate_optional_sensible_regex_at_top_level(caplog):
|
||||
config_obj = {
|
||||
'files': 'dir/*.py',
|
||||
'repos': [],
|
||||
}
|
||||
cfgv.validate(config_obj, CONFIG_SCHEMA)
|
||||
|
||||
assert caplog.record_tuples == [
|
||||
(
|
||||
'pre_commit',
|
||||
logging.WARNING,
|
||||
"The top-level 'files' field is a regex, not a glob -- matching "
|
||||
"'/*' probably isn't what you want here",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fn', (validate_config_main, validate_manifest_main))
|
||||
def test_mains_not_ok(tmpdir, fn):
|
||||
not_yaml = tmpdir.join('f.notyaml')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue