mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add warning for regular expression with [\/] (#2043)
This commit is contained in:
parent
530dbe69ce
commit
cef9c4af03
2 changed files with 73 additions and 23 deletions
|
|
@ -143,6 +143,18 @@ class OptionalSensibleRegexAtHook(cfgv.OptionalNoDefault):
|
|||
f"regex, not a glob -- matching '/*' probably isn't what you "
|
||||
f'want here',
|
||||
)
|
||||
if r'[\/]' in dct.get(self.key, ''):
|
||||
logger.warning(
|
||||
fr'pre-commit normalizes slashes in the {self.key!r} field '
|
||||
fr'in hook {dct.get("id")!r} to forward slashes, so you '
|
||||
fr'can use / instead of [\/]',
|
||||
)
|
||||
if r'[/\\]' in dct.get(self.key, ''):
|
||||
logger.warning(
|
||||
fr'pre-commit normalizes slashes in the {self.key!r} field '
|
||||
fr'in hook {dct.get("id")!r} to forward slashes, so you '
|
||||
fr'can use / instead of [/\\]',
|
||||
)
|
||||
|
||||
|
||||
class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
|
||||
|
|
@ -154,6 +166,18 @@ class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
|
|||
f'The top-level {self.key!r} field is a regex, not a glob -- '
|
||||
f"matching '/*' probably isn't what you want here",
|
||||
)
|
||||
if r'[\/]' in dct.get(self.key, ''):
|
||||
logger.warning(
|
||||
fr'pre-commit normalizes the slashes in the top-level '
|
||||
fr'{self.key!r} field to forward slashes, so you can use / '
|
||||
fr'instead of [\/]',
|
||||
)
|
||||
if r'[/\\]' in dct.get(self.key, ''):
|
||||
logger.warning(
|
||||
fr'pre-commit normalizes the slashes in the top-level '
|
||||
fr'{self.key!r} field to forward slashes, so you can use / '
|
||||
fr'instead of [/\\]',
|
||||
)
|
||||
|
||||
|
||||
class MigrateShaToRev:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue