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 os
|
||||
import shlex
|
||||
|
||||
from pre_commit import five
|
||||
from pre_commit.languages import helpers
|
||||
|
|
@ -83,8 +82,8 @@ def run_hook(repo_cmd_runner, hook, file_args):
|
|||
# automated cleanup of docker images.
|
||||
build_docker_image(repo_cmd_runner, pull=False)
|
||||
|
||||
entry_parts = shlex.split(hook['entry'])
|
||||
entry_executable, entry_args = entry_parts[0], entry_parts[1:]
|
||||
hook_cmd = helpers.to_cmd(hook)
|
||||
entry_executable, cmd_rest = hook_cmd[0], hook_cmd[1:]
|
||||
|
||||
cmd = (
|
||||
'docker', 'run',
|
||||
|
|
@ -94,6 +93,6 @@ def run_hook(repo_cmd_runner, hook, file_args):
|
|||
'--workdir', '/src',
|
||||
'--entrypoint', entry_executable,
|
||||
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
|
||||
|
||||
import shlex
|
||||
|
||||
from pre_commit.util import cmd_output
|
||||
|
||||
|
||||
|
|
@ -12,3 +14,7 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
|
|||
return None
|
||||
else:
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
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 pre_commit.languages import helpers
|
||||
from pre_commit.xargs import xargs
|
||||
|
||||
|
||||
|
|
@ -16,7 +17,6 @@ def install_environment(
|
|||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
return xargs(
|
||||
(repo_cmd_runner.prefix_dir + hook['entry'],) + tuple(hook['args']),
|
||||
file_args,
|
||||
)
|
||||
cmd = helpers.to_cmd(hook)
|
||||
cmd = (repo_cmd_runner.prefix_dir + cmd[0],) + cmd[1:]
|
||||
return xargs(cmd, file_args)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import shlex
|
||||
|
||||
from pre_commit.languages import helpers
|
||||
from pre_commit.xargs import xargs
|
||||
|
||||
|
||||
|
|
@ -18,6 +17,4 @@ def install_environment(
|
|||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
return xargs(
|
||||
tuple(shlex.split(hook['entry'])) + tuple(hook['args']), file_args,
|
||||
)
|
||||
return xargs(helpers.to_cmd(hook), file_args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue