Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release-notes): Improve cli operations for generating release notes #514

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading