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 aa430bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .tools/readmes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

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 aa430bd

Please sign in to comment.