Make shlex behaviour of entry more consistent · precommit/pre-commit@6055af8 · GitHub
Skip to content

Commit 6055af8

Browse files
committed
Make shlex behaviour of entry more consistent
1 parent 0de174f commit 6055af8

7 files changed

Lines changed: 19 additions & 17 deletions

File tree

pre_commit/languages/docker.py

Lines changed: 4 additions & 5 deletions

pre_commit/languages/helpers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import unicode_literals
22

3+
import shlex
4+
35
from pre_commit.util import cmd_output
46

57

@@ -12,3 +14,7 @@ def environment_dir(ENVIRONMENT_DIR, language_version):
1214
return None
1315
else:
1416
return '{}-{}'.format(ENVIRONMENT_DIR, language_version)
17+
18+
19+
def to_cmd(hook):
20+
return tuple(shlex.split(hook['entry'])) + tuple(hook['args'])

pre_commit/languages/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ def install_environment(
6464

6565
def run_hook(repo_cmd_runner, hook, file_args):
6666
with in_env(repo_cmd_runner, hook['language_version']):
67-
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
67+
return xargs(helpers.to_cmd(hook), file_args)

pre_commit/languages/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ def install_environment(
8383

8484
def run_hook(repo_cmd_runner, hook, file_args):
8585
with in_env(repo_cmd_runner, hook['language_version']):
86-
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
86+
return xargs(helpers.to_cmd(hook), file_args)

pre_commit/languages/ruby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ def install_environment(
128128

129129
def run_hook(repo_cmd_runner, hook, file_args):
130130
with in_env(repo_cmd_runner, hook['language_version']):
131-
return xargs((hook['entry'],) + tuple(hook['args']), file_args)
131+
return xargs(helpers.to_cmd(hook), file_args)

pre_commit/languages/script.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import unicode_literals
22

3+
from pre_commit.languages import helpers
34
from pre_commit.xargs import xargs
45

56

@@ -16,7 +17,6 @@ def install_environment(
1617

1718

1819
def run_hook(repo_cmd_runner, hook, file_args):
19-
return xargs(
20-
(repo_cmd_runner.prefix_dir + hook['entry'],) + tuple(hook['args']),
21-
file_args,
22-
)
20+
cmd = helpers.to_cmd(hook)
21+
cmd = (repo_cmd_runner.prefix_dir + cmd[0],) + cmd[1:]
22+
return xargs(cmd, file_args)

pre_commit/languages/system.py

Lines changed: 2 additions & 5 deletions

0 commit comments

Comments
 (0)