mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix filenames with spaces in them.
This commit is contained in:
parent
061ac81682
commit
2ec7a34035
8 changed files with 25 additions and 7 deletions
|
|
@ -2,12 +2,12 @@ from __future__ import unicode_literals
|
|||
|
||||
|
||||
def file_args_to_stdin(file_args):
|
||||
return '\n'.join(list(file_args) + [''])
|
||||
return '\0'.join(list(file_args) + [''])
|
||||
|
||||
|
||||
def run_hook(env, hook, file_args):
|
||||
return env.run(
|
||||
' '.join(['xargs', hook['entry']] + hook['args']),
|
||||
' '.join(['xargs', '-0', hook['entry']] + hook['args']),
|
||||
stdin=file_args_to_stdin(file_args),
|
||||
retcode=None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ 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',
|
||||
'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'])),
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def install_environment(repo_cmd_runner, version='default'):
|
|||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
return repo_cmd_runner.run(
|
||||
['xargs', '{{prefix}}{0}'.format(hook['entry'])] + hook['args'],
|
||||
['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,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ def install_environment(repo_cmd_runner, version='default'):
|
|||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
return repo_cmd_runner.run(
|
||||
['xargs'] + shlex.split(hook['entry']) + hook['args'],
|
||||
['xargs', '-0'] + shlex.split(hook['entry']) + hook['args'],
|
||||
stdin=file_args_to_stdin(file_args),
|
||||
retcode=None,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue