From 1763c73dfacc63848b96ae7fe9029cb91dc9ad9d Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sun, 24 Jul 2022 00:35:51 +0200 Subject: [PATCH] Ensure exactly one trailing newline in rendered spec files --- rust2rpm/__main__.py | 1 - rust2rpm/generator.py | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 7c5ceef..ac3f1c4 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -584,7 +584,6 @@ def main(): else: with open(spec_file, "w") as fobj: fobj.write(spec_contents) - fobj.write("\n") print(f'Wrote {fobj.name}') for fname, diff in zip(patch_files, diffs): if fname: diff --git a/rust2rpm/generator.py b/rust2rpm/generator.py index 63b595f..ef3aded 100644 --- a/rust2rpm/generator.py +++ b/rust2rpm/generator.py @@ -109,6 +109,9 @@ def spec_file_render( metadata=metadata, patch_file_manual=patch_file_manual, patch_file_automatic=patch_file_automatic, - **kwargs) + '\n' + **kwargs) + + if not spec_contents.endswith("\n"): + spec_contents += "\n" return spec_contents