From ef29a6a59a0e35edafcaccbdaa034e4cda6bceab Mon Sep 17 00:00:00 2001 From: David Lynch Date: Sat, 27 Jul 2024 01:19:22 -0500 Subject: [PATCH] Fix changelogs that only contain one version Fixes #1 --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 49e365c..315d2ee 100644 --- a/main.py +++ b/main.py @@ -11,12 +11,16 @@ def main(full_changelog, output): for line in f: if line.startswith('##') and not line.startswith('###'): if matching: - print("Wrote changelog to", output) - return + return output matching = True if matching: out.write(line) + if matching: + # There was only one version in the changelog, so we hit the end of + # the file while still matching + return output sys.exit("Couldn't write changelog") if __name__ == '__main__': - main(sys.argv[1], sys.argv[2]) + output = main(sys.argv[1], sys.argv[2]) + print("Wrote changelog to", output)