fix: change subprocess.Popen calls to work on Linux too (#14689)
* fix: remove 'shell=True' when calling 'git diff' Calling subprocess.Popen() with a list of args and shell=True causes the args to be ignored, so ['git', 'diff', '--name-only', '--staged'] was turning into just 'git'. Instead of getting a list of changed files, we got the --help message. Two possible fixes: change it from a list to a single string, or remove 'shell=True'. The shell doesn't seem to be needed, so I chose that. More reading: https://stackoverflow.com/questions/26417658/subprocess-call-arguments-ignored-when-using-shell-true-w-list * fix: remove 'shell=True' when calling clang-format Same problem / rationale as previous commit. * fix: re-add shell=True for win; use different fix
This commit is contained in:
parent
977e287cfa
commit
1b3fdb18e3
1 changed files with 4 additions and 4 deletions
|
@ -107,11 +107,11 @@ def run_clang_format_diff(args, file_name):
|
||||||
invocation = [args.clang_format_executable, file_name]
|
invocation = [args.clang_format_executable, file_name]
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
invocation,
|
' '.join(invocation),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
shell = True)
|
shell=True)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
raise DiffError(str(exc))
|
raise DiffError(str(exc))
|
||||||
proc_stdout = proc.stdout
|
proc_stdout = proc.stdout
|
||||||
|
@ -253,10 +253,10 @@ def main():
|
||||||
parse_files = []
|
parse_files = []
|
||||||
if args.changed:
|
if args.changed:
|
||||||
popen = subprocess.Popen(
|
popen = subprocess.Popen(
|
||||||
["git", "diff", "--name-only", "--cached"],
|
'git diff --name-only --cached',
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
shell = True
|
shell=True
|
||||||
)
|
)
|
||||||
for line in popen.stdout:
|
for line in popen.stdout:
|
||||||
file_name = line.rstrip()
|
file_name = line.rstrip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue