mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fixes lots of files problem. Closes #34
This commit is contained in:
parent
6cda5bfe27
commit
f66b3f6156
2 changed files with 13 additions and 15 deletions
|
|
@ -1,16 +1,11 @@
|
||||||
|
|
||||||
from plumbum import local
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def run_hook(env, hook, file_args):
|
def run_hook(env, hook, file_args):
|
||||||
return env.run(
|
return env.run(
|
||||||
' '.join([hook['entry']] + hook.get('args', []) + list(file_args)),
|
' '.join(['xargs', hook['entry']] + hook.get('args', [])),
|
||||||
retcode=None,
|
stdin='\n'.join(list(file_args) + ['']),
|
||||||
)
|
|
||||||
return env.run(
|
|
||||||
' '.join(['xargs |', hook['entry']] + hook.get('args', [])),
|
|
||||||
retcode=None,
|
|
||||||
stdin='\n'.join(file_args) + '\n',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,9 +24,14 @@ class Environment(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def run(self, cmd, **kwargs):
|
def run(self, cmd, stdin=None, **kwargs):
|
||||||
"""Returns (returncode, stdout, stderr)."""
|
"""Returns (returncode, stdout, stderr)."""
|
||||||
return local['bash'][
|
proc = subprocess.Popen(
|
||||||
'-c',
|
['bash', '-c', ' '.join([self.env_prefix, cmd])],
|
||||||
' '.join([self.env_prefix, cmd])
|
stdin=subprocess.PIPE,
|
||||||
].run(**kwargs)
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
stdout, stderr = proc.communicate(stdin)
|
||||||
|
|
||||||
|
return proc.returncode, stdout, stderr
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ def test_run_a_python_hook(config_for_python_pre_commit_git_repo):
|
||||||
assert ret[1] == "['/dev/null']\nHello World\n"
|
assert ret[1] == "['/dev/null']\nHello World\n"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo):
|
def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo):
|
||||||
repo = Repository(config_for_python_pre_commit_git_repo)
|
repo = Repository(config_for_python_pre_commit_git_repo)
|
||||||
|
|
@ -60,7 +59,6 @@ def test_run_a_hook_lots_of_files(config_for_python_pre_commit_git_repo):
|
||||||
ret = repo.run_hook('foo', ['/dev/null'] * 15000)
|
ret = repo.run_hook('foo', ['/dev/null'] * 15000)
|
||||||
|
|
||||||
assert ret[0] == 0
|
assert ret[0] == 0
|
||||||
assert ret[1] == 'Hello World\n'
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue