commit 5b10c8bcd89aa7b842a20c8650a05619e6b23af5 Author: Marco Miller Date: Wed Oct 14 11:50:59 2020 -0400 Replace flaky Popen with subprocess.check_output in release_noter Before this change, comparing consecutive release_noter runs led to slightly differing generated markdown files, over time. With this change, such differences are not noticed anymore, and the resulting markdown consistently has more content in it (which was missing before). Change-Id: Iac9102181c6fc8416228fd525cc331cf030afc78 diff --git a/tools/release_noter/release_noter.py b/tools/release_noter/release_noter.py index bc39d36..eb00d5d 100644 --- a/tools/release_noter/release_noter.py +++ b/tools/release_noter/release_noter.py @@ -104,12 +104,10 @@ def newly_released(commit_sha1, release): "--contains", commit_sha1, ] - process = subprocess.Popen(git_tag, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.check_output(git_tag, stderr=subprocess.PIPE, encoding=UTF8) verdict = True - for line in iter(process.stdout.readline, ""): - if process.poll() is not None: - break - line = line.strip().decode(UTF8) + for line in process.splitlines(): + line = line.strip() if not re.match(rf"{re.escape(release)}$", line): # Wrongfully pushed or malformed tags ignored. # Preceding release-candidate (-rcN) tags treated as newly released. @@ -124,7 +122,7 @@ def open_git_log(options): "--no-merges", options.range, ] - return subprocess.Popen(git_log, stdout=subprocess.PIPE) + return subprocess.check_output(git_log, encoding=UTF8) class Change: @@ -164,10 +162,8 @@ def parse_log(process, release): submodules = dict() submodule_change = None task = Task.start_commit - for line in iter(process.stdout.readline, ""): - if process.poll() is not None: - break - line = line.strip().decode(UTF8) + for line in process.splitlines(): + line = line.strip() if not line: continue if task == Task.start_commit: