From 74b590fc9e3a3340eb6f0000074c4f959946b211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 21 Jun 2024 11:53:43 +0200 Subject: [PATCH] feat(release-notes): Improve cli operations for generating release notes --- release-controller/release_notes.py | 29 +++++++++++++++++++++++++++++ scripts/release-notes.py | 8 ++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/release-controller/release_notes.py b/release-controller/release_notes.py index bf1fd78dd..89cfeeb88 100755 --- a/release-controller/release_notes.py +++ b/release-controller/release_notes.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +import argparse import fnmatch +import os import pathlib import re import subprocess @@ -509,3 +511,30 @@ def release_notes(first_commit, last_commit, release_name) -> str: notes += "* " + text + "\n" return notes + + +def main(): + parser = argparse.ArgumentParser(description="Generate release notes") + parser.add_argument("first_commit", type=str, help="first commit") + parser.add_argument("last_commit", type=str, help="last commit") + parser.add_argument( + "--max-commits", + dest="max_commits", + default=os.environ.get("MAX_COMMITS", 1000), + help="maximum number of commits to fetch", + ) + parser.add_argument( + "--html", + type=str, + dest="html_path", + default="$HOME/Downloads/release-notes.html", + help="path to where the output should be generated", + ) + parser.add_argument("rc_name", type=str, help="name of the release i.e. 'rc--2023-01-12_18-31'") + args = parser.parse_args() + + print(release_notes(args.first_commit, args.last_commit, args.rc_name)) + + +if __name__ == "__main__": + main() diff --git a/scripts/release-notes.py b/scripts/release-notes.py index c1aeb936f..718b485e9 100755 --- a/scripts/release-notes.py +++ b/scripts/release-notes.py @@ -87,10 +87,9 @@ parser.add_argument( "--max-commits", dest="max_commits", - default=1000, + default=os.environ.get("MAX_COMMITS", 1000), help="maximum number of commits to fetch", ) -parser.add_argument("--branch", dest="branch", default="master", help="branch to fetch commits from") parser.add_argument( "--html", type=str, @@ -101,9 +100,6 @@ parser.add_argument("rc_name", type=str, help="name of the release i.e. 'rc--2023-01-12_18-31'") args = parser.parse_args() -max_commits = os.environ.get("MAX_COMMITS", args.max_commits) -branch = os.environ.get("BRANCH", args.branch) - # https://stackoverflow.com/a/34482761 def progressbar(it, prefix="", size=60, out=sys.stdout): # Python3.6+ @@ -352,7 +348,7 @@ def main(): print("Commit: {} ==> using commit: {}".format(commit_hash, used_commit)) commits[i] = commits[i] + (used_commit,) - if len(commits) == max_commits: + if len(commits) == args.max_commits: print("WARNING: max commits limit reached, increase depth") exit(1)