Skip to content

Commit 4cc41f8

Browse files
committed
run-task: clean up subprocess usage in _clean_git_checkout
This was copied from `run_command` in 8d7d8b1, but some stuff doesn't make sense here: - we don't stream the output to our log so we don't need to disable buffering or go through a TextIOWrapper - we don't want to pass our stdin to the command Instead we can use subprocess.run and let it capture stdout and check the returncode.
1 parent 8f23f5f commit 4cc41f8

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/taskgraph/run-task/run-task

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -597,26 +597,17 @@ def _clean_git_checkout(destination_path):
597597
"-nxdff",
598598
]
599599
print_line(b"vcs", b"executing %r\n" % args)
600-
p = subprocess.Popen(
600+
p = subprocess.run(
601601
args,
602-
# Disable buffering because we want to receive output
603-
# as it is generated so timestamps in logs are
604-
# accurate.
605-
bufsize=0,
606-
stdout=subprocess.PIPE,
607-
stdin=sys.stdin.fileno(),
602+
stdout=subprocess.PIPE
608603
cwd=destination_path,
609604
env=os.environ,
605+
check=True,
610606
)
611-
stdout = io.TextIOWrapper(p.stdout, encoding="latin1")
612-
ret = p.wait()
613-
if ret:
614-
sys.exit(ret)
615-
data = stdout.read()
616607
prefix = "Would remove "
617608
filenames = [
618609
os.path.join(destination_path, line[len(prefix) :])
619-
for line in data.splitlines()
610+
for line in p.stdout.splitlines()
620611
]
621612
print_line(b"vcs", b"removing %r\n" % filenames)
622613
for filename in filenames:

0 commit comments

Comments
 (0)