Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eefeaaf

Browse files
authored
Merge pull request #626 from pre-commit/pipes_quote_more
Use pipes.quote for executable path
2 parents 6b81fe9 + 873dd17 commit eefeaaf

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

pre_commit/commands/install_uninstall.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import io
55
import os.path
6+
import pipes
67
import sys
78

89
from pre_commit import output
@@ -68,7 +69,7 @@ def install(
6869

6970
skip_on_missing_conf = 'true' if skip_on_missing_conf else 'false'
7071
contents = io.open(resource_filename('hook-tmpl')).read().format(
71-
sys_executable=sys.executable,
72+
sys_executable=pipes.quote(sys.executable),
7273
hook_type=hook_type,
7374
hook_specific=hook_specific_contents,
7475
config_file=runner.config_file,

pre_commit/resources/hook-tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ popd > /dev/null
99
retv=0
1010
args=""
1111

12-
ENV_PYTHON='{sys_executable}'
12+
ENV_PYTHON={sys_executable}
1313
SKIP_ON_MISSING_CONF={skip_on_missing_conf}
1414

1515
which pre-commit >& /dev/null

tests/commands/install_uninstall_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import io
66
import os.path
7+
import pipes
78
import re
89
import shutil
910
import subprocess
@@ -54,7 +55,7 @@ def test_install_pre_commit(tempdir_factory):
5455
pre_commit_contents = io.open(runner.pre_commit_path).read()
5556
pre_commit_script = resource_filename('hook-tmpl')
5657
expected_contents = io.open(pre_commit_script).read().format(
57-
sys_executable=sys.executable,
58+
sys_executable=pipes.quote(sys.executable),
5859
hook_type='pre-commit',
5960
hook_specific='',
6061
config_file=runner.config_file,
@@ -70,7 +71,7 @@ def test_install_pre_commit(tempdir_factory):
7071
pre_push_tmpl = resource_filename('pre-push-tmpl')
7172
pre_push_template_contents = io.open(pre_push_tmpl).read()
7273
expected_contents = io.open(pre_commit_script).read().format(
73-
sys_executable=sys.executable,
74+
sys_executable=pipes.quote(sys.executable),
7475
hook_type='pre-push',
7576
hook_specific=pre_push_template_contents,
7677
config_file=runner.config_file,

0 commit comments

Comments
 (0)