Skip to content

Commit

Permalink
Ensure ending newline in renderer, rather than renderer and diff
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther committed Nov 27, 2024
1 parent ab6a7d9 commit 205080c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .tools/readmes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ 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"
return current
except FileNotFoundError:
return ""

Expand Down
6 changes: 0 additions & 6 deletions .tools/readmes/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 205080c

Please sign in to comment.