diff --git a/script/release_notes.py b/script/release_notes.py index 8c97a0395daa..f55ba87de129 100755 --- a/script/release_notes.py +++ b/script/release_notes.py @@ -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') @@ -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))