diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-27 16:04:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-27 16:04:10 +0000 |
commit | a971f38b11f5955f6ea4f7922233d8324a5c6753 (patch) | |
tree | 5a424740e9cee97bc1c8053fea07db935c27b659 /pre_commit/clientlib.py | |
parent | Adding upstream version 2.8.2. (diff) | |
download | pre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.tar.xz pre-commit-a971f38b11f5955f6ea4f7922233d8324a5c6753.zip |
Adding upstream version 2.9.3.upstream/2.9.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | pre_commit/clientlib.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pre_commit/clientlib.py b/pre_commit/clientlib.py index 87679bf..20d4492 100644 --- a/pre_commit/clientlib.py +++ b/pre_commit/clientlib.py @@ -61,6 +61,7 @@ MANIFEST_HOOK_DICT = cfgv.Map( cfgv.Optional('files', check_string_regex, ''), cfgv.Optional('exclude', check_string_regex, '^$'), cfgv.Optional('types', cfgv.check_array(check_type_tag), ['file']), + cfgv.Optional('types_or', cfgv.check_array(check_type_tag), []), cfgv.Optional('exclude_types', cfgv.check_array(check_type_tag), []), cfgv.Optional( @@ -111,6 +112,18 @@ LOCAL = 'local' META = 'meta' +class OptionalSensibleRegex(cfgv.OptionalNoDefault): + def check(self, dct: Dict[str, Any]) -> None: + super().check(dct) + + if '/*' in dct.get(self.key, ''): + logger.warning( + f'The {self.key!r} field in hook {dct.get("id")!r} is a ' + f"regex, not a glob -- matching '/*' probably isn't what you " + f'want here', + ) + + class MigrateShaToRev: key = 'rev' @@ -226,6 +239,8 @@ CONFIG_HOOK_DICT = cfgv.Map( for item in MANIFEST_HOOK_DICT.items if item.key != 'id' ), + OptionalSensibleRegex('files', cfgv.check_string), + OptionalSensibleRegex('exclude', cfgv.check_string), ) CONFIG_REPO_DICT = cfgv.Map( 'Repository', 'repo', |