Skip to content

Commit

Permalink
git pre commit hook: use shlex.split()
Browse files Browse the repository at this point in the history
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
  • Loading branch information
giampaolo committed Dec 15, 2021
1 parent 39dc44b commit ebbaae8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scripts/internal/git_pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from __future__ import print_function

import os
import shlex
import subprocess
import sys

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ebbaae8

Please sign in to comment.