mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
39 lines
971 B
Python
39 lines
971 B
Python
from __future__ import unicode_literals
|
|
|
|
from sys import platform
|
|
|
|
from pre_commit.util import shell_escape
|
|
from pre_commit.xargs import xargs
|
|
|
|
|
|
ENVIRONMENT_DIR = None
|
|
|
|
|
|
def install_environment(
|
|
repo_cmd_runner,
|
|
version='default',
|
|
additional_dependencies=(),
|
|
):
|
|
"""Installation for pcre type is a noop."""
|
|
raise AssertionError('Cannot install pcre repo.')
|
|
|
|
|
|
def run_hook(repo_cmd_runner, hook, file_args):
|
|
grep_command = '{0} -H -n -P'.format(
|
|
'ggrep' if platform == 'darwin' else 'grep',
|
|
)
|
|
|
|
# For PCRE the entry is the regular expression to match
|
|
return xargs(
|
|
(
|
|
'sh', '-c',
|
|
# Grep usually returns 0 for matches, and nonzero for non-matches
|
|
# so we flip it here.
|
|
'! {0} {1} {2} $@'.format(
|
|
grep_command, ' '.join(hook['args']),
|
|
shell_escape(hook['entry']),
|
|
),
|
|
'--',
|
|
),
|
|
file_args,
|
|
)
|