diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2021-12-15 11:07:37 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2021-12-15 11:07:37 +0100 |
commit | ebbaae8d1f42f051282af79d60f19cb1161088a5 (patch) | |
tree | 7b1d20ab0e789b498bcd82de277b5fe86fbdfd25 /scripts/internal/git_pre_commit.py | |
parent | 39dc44bfa5fbb9500166b3480295379602e5bbc5 (diff) | |
download | psutil-ebbaae8d1f42f051282af79d60f19cb1161088a5.tar.gz |
git pre commit hook: use shlex.split()
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Diffstat (limited to 'scripts/internal/git_pre_commit.py')
-rwxr-xr-x | scripts/internal/git_pre_commit.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index 92bc0f0a..dca17ffb 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -22,6 +22,7 @@ Install this with "make install-git-hooks". from __future__ import print_function import os +import shlex import subprocess import sys @@ -118,24 +119,21 @@ def main(): # Python linters if py_files: - # Flake8 + # flake8 assert os.path.exists('.flake8') - # XXX: we should escape spaces and possibly other amenities here cmd = "%s -m flake8 --config=.flake8 %s" % (PYTHON, " ".join(py_files)) - ret = subprocess.call(cmd, shell=True) + ret = subprocess.call(shlex.split(cmd)) if ret != 0: return exit("python code is not flake8 compliant; " "try running 'make fix-flake8'") - # isort assert os.path.exists('.isort.cfg') cmd = "%s -m isort --settings=.isort.cfg --check-only %s" % ( PYTHON, " ".join(py_files)) - ret = subprocess.call(cmd, shell=True) + ret = subprocess.call(shlex.split(cmd)) if ret != 0: return exit("python code is not flake8 compliant; " "try running 'make fix-imports'") - # C linter if c_files: # XXX: we should escape spaces and possibly other amenities here |