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]
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
invocation,
|
||||
' '.join(invocation),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
shell = True)
|
||||
shell=True)
|
||||
except OSError as exc:
|
||||
raise DiffError(str(exc))
|
||||
proc_stdout = proc.stdout
|
||||
|
@ -253,10 +253,10 @@ def main():
|
|||
parse_files = []
|
||||
if args.changed:
|
||||
popen = subprocess.Popen(
|
||||
["git", "diff", "--name-only", "--cached"],
|
||||
'git diff --name-only --cached',
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
shell = True
|
||||
shell=True
|
||||
)
|
||||
for line in popen.stdout:
|
||||
file_name = line.rstrip()
|
||||
|
|
Loading…
Reference in a new issue