예제 #1
0
파일: script.py 프로젝트: bchess/pre-commit
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ['xargs', '-0', '{{prefix}}{0}'.format(hook['entry'])] + hook['args'],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #2
0
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ['xargs', '-0', '{{prefix}}{0}'.format(hook['entry'])] + hook['args'],
        # TODO: this is duplicated in pre_commit/languages/helpers.py
        stdin=file_args_to_stdin(file_args),
        retcode=None,
    )
예제 #3
0
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ['xargs', '-0', '{{prefix}}{0}'.format(hook['entry'])] + hook['args'],
        # TODO: this is duplicated in pre_commit/languages/helpers.py
        stdin=file_args_to_stdin(file_args),
        retcode=None,
    )
예제 #4
0
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ['xargs', '-0'] + shlex.split(hook['entry']) + hook['args'],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #5
0
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ['xargs', '-0'] + shlex.split(hook['entry']) + hook['args'],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #6
0
def run_hook(repo_cmd_runner, hook, file_args):
    return repo_cmd_runner.run(
        ["xargs", "-0", "{{prefix}}{0}".format(hook["entry"])] + hook["args"],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #7
0
파일: pcre.py 프로젝트: meunierd/pre-commit
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', '-0', '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,
        encoding=None,
    )
예제 #8
0
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',
            '-0',
            '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,
    )
예제 #9
0
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",
            "-0",
            "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,
    )
예제 #10
0
파일: pcre.py 프로젝트: hitul007/pre-commit
def run_hook(repo_cmd_runner, hook, file_args):
    grep_command = 'grep -H -n -P'
    if platform == 'darwin':  # pragma: no cover (osx)
        grep_command = 'ggrep -H -n -P'

    # For PCRE the entry is the regular expression to match
    return repo_cmd_runner.run(
        [
            'xargs', '-0', 'sh', '-c',
            # Grep usually returns 0 for matches, and nonzero for non-matches
            # so we flip it here.
            '! {0} {1} $@'.format(grep_command, shell_escape(hook['entry'])),
            '--',
        ],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #11
0
파일: pcre.py 프로젝트: imbstack/pre-commit
def run_hook(repo_cmd_runner, hook, file_args):
    grep_command = "grep -H -n -P"
    if platform == "darwin":  # pragma: no cover (osx)
        grep_command = "ggrep -H -n -P"

    # For PCRE the entry is the regular expression to match
    return repo_cmd_runner.run(
        [
            "xargs",
            "-0",
            "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"])),
            "--",
        ],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #12
0
def run_hook(repo_cmd_runner, hook, file_args):
    grep_command = 'grep -H -n -P'
    if platform == 'darwin':  # pragma: no cover (osx)
        grep_command = 'ggrep -H -n -P'

    # For PCRE the entry is the regular expression to match
    return repo_cmd_runner.run(
        [
            'xargs',
            '-0',
            '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'])),
            '--',
        ],
        stdin=file_args_to_stdin(file_args),
        retcode=None,
        encoding=None,
    )
예제 #13
0
def test_file_args_to_stdin_empty():
    assert file_args_to_stdin([]) == ''
예제 #14
0
def test_file_args_to_stdin_tuple():
    assert file_args_to_stdin(('foo', 'bar')) == 'foo\0bar\0'
예제 #15
0
def test_file_args_to_stdin_some():
    assert file_args_to_stdin(['foo', 'bar']) == 'foo\0bar\0'