Skip to content

Commit

Permalink
chore: report total commits by category in release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em committed Feb 3, 2025
1 parent 142874d commit 77c7c68
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions script/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ def format_markdown_description(pr_number, description):
link = f"[#{pr_number}](https://github.com/leanprover/lean4/pull/{pr_number})"
return f"{link} {description}"

def count_commit_types(commits):
counts = {
'total': len(commits),
'feat': 0,
'fix': 0,
'refactor': 0,
'doc': 0,
'chore': 0
}

for _, first_line, _ in commits:
for commit_type in ['feat:', 'fix:', 'refactor:', 'doc:', 'chore:']:
if first_line.startswith(commit_type):
counts[commit_type.rstrip(':')] += 1
break

return counts

def main():
parser = argparse.ArgumentParser(description='Generate release notes from Git commits')
parser.add_argument('--since', required=True, help='Git tag to generate release notes since')
Expand Down Expand Up @@ -132,6 +150,13 @@ def main():
for label in changelog_labels:
changelog[label].append((pr_number, markdown_description))

# Add commit type counting
counts = count_commit_types(commits)
print(f"For this release, {counts['total']} changes landed. "
f"In addition to the {counts['feat']} feature additions and {counts['fix']} fixes listed below "
f"there were {counts['refactor']} refactoring changes, {counts['doc']} documentation improvements "
f"and {counts['chore']} chores.\n")

section_order = sort_sections_order()
sorted_changelog = sorted(changelog.items(), key=lambda item: section_order.index(format_section_title(item[0])) if format_section_title(item[0]) in section_order else len(section_order))

Expand Down

0 comments on commit 77c7c68

Please sign in to comment.