summaryrefslogtreecommitdiffstats
path: root/pre_commit/clientlib.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-27 16:04:26 +0000
commit7ad3acc8faa151e307c82b659f884205ef47012b (patch)
treeda74df356ea350b3ee9fb0bf71937e0bdb7896a6 /pre_commit/clientlib.py
parentReleasing debian version 2.8.2-1. (diff)
downloadpre-commit-7ad3acc8faa151e307c82b659f884205ef47012b.tar.xz
pre-commit-7ad3acc8faa151e307c82b659f884205ef47012b.zip
Merging upstream version 2.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/clientlib.py')
-rw-r--r--pre_commit/clientlib.py15
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',