mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Make shlex behaviour of entry more consistent
This commit is contained in:
parent
0de174f2ac
commit
6055af8bc8
7 changed files with 19 additions and 17 deletions
|
|
@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import shlex
|
|
||||||
|
|
||||||
from pre_commit import five
|
from pre_commit import five
|
||||||
from pre_commit.languages import helpers
|
from pre_commit.languages import helpers
|
||||||
|
|
@ -83,8 +82,8 @@ def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
# automated cleanup of docker images.
|
# automated cleanup of docker images.
|
||||||
build_docker_image(repo_cmd_runner, pull=False)
|
build_docker_image(repo_cmd_runner, pull=False)
|
||||||
|
|
||||||
entry_parts = shlex.split(hook['entry'])
|
hook_cmd = helpers.to_cmd(hook)
|
||||||
entry_executable, entry_args = entry_parts[0], entry_parts[1:]
|
entry_executable, cmd_rest = hook_cmd[0], hook_cmd[1:]
|
||||||
|
|
||||||
cmd = (
|
cmd = (
|
||||||
'docker', 'run',
|
'docker', 'run',
|
||||||
|
|
@ -94,6 +93,6 @@ def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
'--workdir', '/src',
|
'--workdir', '/src',
|
||||||
'--entrypoint', entry_executable,
|
'--entrypoint', entry_executable,
|
||||||
docker_tag(repo_cmd_runner)
|
docker_tag(repo_cmd_runner)
|
||||||
)
|
) + cmd_rest
|
||||||
|
|
||||||
return xargs(cmd + tuple(entry_args) + tuple(hook['args']), file_args)
|
return xargs(cmd, file_args)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import shlex
|
||||||
|
|
||||||
from pre_commit.util import cmd_output
|
from pre_commit.util import cmd_output
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,3 +14,7 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return '{}-{}'.format(ENVIRONMENT_DIR, language_version)
|
return '{}-{}'.format(ENVIRONMENT_DIR, language_version)
|
||||||
|
|
||||||
|
|
||||||
|
def to_cmd(hook):
|
||||||
|
return tuple(shlex.split(hook['entry'])) + tuple(hook['args'])
|
||||||
|
|
|
||||||
|
|
@ -64,4 +64,4 @@ def install_environment(
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
with in_env(repo_cmd_runner, hook['language_version']):
|
with in_env(repo_cmd_runner, hook['language_version']):
|
||||||
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
|
return xargs(helpers.to_cmd(hook), file_args)
|
||||||
|
|
|
||||||
|
|
@ -83,4 +83,4 @@ def install_environment(
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
with in_env(repo_cmd_runner, hook['language_version']):
|
with in_env(repo_cmd_runner, hook['language_version']):
|
||||||
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
|
return xargs(helpers.to_cmd(hook), file_args)
|
||||||
|
|
|
||||||
|
|
@ -128,4 +128,4 @@ def install_environment(
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
with in_env(repo_cmd_runner, hook['language_version']):
|
with in_env(repo_cmd_runner, hook['language_version']):
|
||||||
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
|
return xargs(helpers.to_cmd(hook), file_args)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from pre_commit.languages import helpers
|
||||||
from pre_commit.xargs import xargs
|
from pre_commit.xargs import xargs
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,7 +17,6 @@ def install_environment(
|
||||||
|
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
return xargs(
|
cmd = helpers.to_cmd(hook)
|
||||||
(repo_cmd_runner.prefix_dir + hook['entry'],) + tuple(hook['args']),
|
cmd = (repo_cmd_runner.prefix_dir + cmd[0],) + cmd[1:]
|
||||||
file_args,
|
return xargs(cmd, file_args)
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import shlex
|
from pre_commit.languages import helpers
|
||||||
|
|
||||||
from pre_commit.xargs import xargs
|
from pre_commit.xargs import xargs
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,6 +17,4 @@ def install_environment(
|
||||||
|
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
return xargs(
|
return xargs(helpers.to_cmd(hook), file_args)
|
||||||
tuple(shlex.split(hook['entry'])) + tuple(hook['args']), file_args,
|
|
||||||
)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue