From fb21d6ab64406324037454ddd88dd11e4cc75f06 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 16 Feb 2021 02:37:55 -0500 Subject: [PATCH] sync: use subprocess.run to verify tags The code is a bit simpler & easier to reason about. Change-Id: I149729c7d01434b08b58cc9715dcf0f0d11201c2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297022 Reviewed-by: Michael Mortensen Tested-by: Mike Frysinger --- subcmds/sync.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index eda95f96..818f7c8a 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -1086,20 +1086,11 @@ def _VerifyTag(project): env['GNUPGHOME'] = gpg_dir cmd = [GIT, 'tag', '-v', cur] - proc = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env=env) - out = proc.stdout.read() - proc.stdout.close() - - err = proc.stderr.read() - proc.stderr.close() - - if proc.wait() != 0: + result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + env=env, check=False) + if result.returncode: print(file=sys.stderr) - print(out, file=sys.stderr) - print(err, file=sys.stderr) + print(result.stdout, file=sys.stderr) print(file=sys.stderr) return False return True