Skip to content

Commit

Permalink
feat(release-notes): Improve cli operations for generating release no…
Browse files Browse the repository at this point in the history
…tes (#514)
  • Loading branch information
sasa-tomic committed Jun 21, 2024
1 parent 7f91368 commit e00f95d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
29 changes: 29 additions & 0 deletions release-controller/release_notes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
import argparse
import fnmatch
import os
import pathlib
import re
import subprocess
Expand Down Expand Up @@ -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()
8 changes: 2 additions & 6 deletions scripts/release-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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+
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e00f95d

Please sign in to comment.