From aa430bda93a4745c9c39d270949d0d8dec1f0b4b Mon Sep 17 00:00:00 2001 From: David Souther Date: Wed, 27 Nov 2024 10:31:23 -0500 Subject: [PATCH] Ensure ending newline in renderer, rather than renderer and diff --- .tools/readmes/render.py | 5 ++++- .tools/readmes/runner.py | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.tools/readmes/render.py b/.tools/readmes/render.py index bcd03a88591..fe27ce6598a 100644 --- a/.tools/readmes/render.py +++ b/.tools/readmes/render.py @@ -333,7 +333,10 @@ def write(self): def read_current(self): try: with self.readme_filename.open("r", encoding="utf-8") as f: - return f.read() + current = f.read() + if current[-1] != "\n": + # Ensure there's always an ending newline + current += "\n" except FileNotFoundError: return "" diff --git a/.tools/readmes/runner.py b/.tools/readmes/runner.py index 18a5315b7c9..b5691a9c316 100755 --- a/.tools/readmes/runner.py +++ b/.tools/readmes/runner.py @@ -173,12 +173,6 @@ def main(): def make_diff(renderer, id): current = renderer.read_current().split("\n") - if current[-1] != "": - # Ensure final "last" line - current += [""] expected = renderer.readme_text.split("\n") - if expected[-1] != "": - # Ensure final "last" line - expected += [""] diff = unified_diff(current, expected, f"{id}/current", f"{id}/expected") return "\n".join(diff)