repo: show redirects when tracing commands

This copies the output style we use in git_command for showing output
and input redirections.

Change-Id: I449b27e7b262e1b30b24333109a1d91d9c7b1ce7
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256453
Reviewed-by: Jonathan Nieder <jrn@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2020-02-21 23:45:08 -05:00
parent f5dbd2eb07
commit 71928c19a6

11
repo
View File

@ -382,7 +382,16 @@ def run_command(cmd, **kwargs):
# Run & package the results. # Run & package the results.
proc = subprocess.Popen(cmd, **kwargs) proc = subprocess.Popen(cmd, **kwargs)
(stdout, stderr) = proc.communicate(input=cmd_input) (stdout, stderr) = proc.communicate(input=cmd_input)
trace.print(':', ' '.join(cmd)) dbg = ': ' + ' '.join(cmd)
if cmd_input is not None:
dbg += ' 0<|'
if stdout == subprocess.PIPE:
dbg += ' 1>|'
if stderr == subprocess.PIPE:
dbg += ' 2>|'
elif stderr == subprocess.STDOUT:
dbg += ' 2>&1'
trace.print(dbg)
ret = RunResult(proc.returncode, decode(stdout), decode(stderr)) ret = RunResult(proc.returncode, decode(stdout), decode(stderr))
# If things failed, print useful debugging output. # If things failed, print useful debugging output.