mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add pcre type.
This commit is contained in:
parent
38673941dc
commit
2cfd2818b5
11 changed files with 184 additions and 10 deletions
27
pre_commit/languages/pcre.py
Normal file
27
pre_commit/languages/pcre.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from pre_commit.languages.helpers import file_args_to_stdin
|
||||
from pre_commit.util import shell_escape
|
||||
|
||||
|
||||
ENVIRONMENT_DIR = None
|
||||
|
||||
|
||||
def install_environment(repo_cmd_runner, version='default'):
|
||||
"""Installation for pcre type is a noop."""
|
||||
raise AssertionError('Cannot install pcre repo.')
|
||||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
# For PCRE the entry is the regular expression to match
|
||||
return repo_cmd_runner.run(
|
||||
[
|
||||
'xargs', 'sh', '-c',
|
||||
# Grep usually returns 0 for matches, and nonzero for non-matches
|
||||
# so we flip it here.
|
||||
'! grep -H -n -P {0} $@'.format(shell_escape(hook['entry'])),
|
||||
'--',
|
||||
],
|
||||
stdin=file_args_to_stdin(file_args),
|
||||
retcode=None,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue