mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
added warning if globs are used instead of regex
This commit is contained in:
parent
6e37f197b0
commit
610716d3d1
2 changed files with 31 additions and 0 deletions
|
|
@ -112,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'
|
||||
|
||||
|
|
@ -227,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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue