From 28d6f50ce2574d4fdd4fad6c00adbd1dd576222e Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 9 Sep 2025 10:21:12 +0000 Subject: [PATCH 1/4] chore(librarian): various refactoring following #14353 --- .generator/cli.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/.generator/cli.py b/.generator/cli.py index df843c165a7c..f3bb1a76fd15 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -643,22 +643,27 @@ def _process_changelog( entry_parts = [version_header] # Group changes by type (e.g., feat, fix, docs) - library_changes.sort(key=lambda x: x["type"]) - grouped_changes = itertools.groupby(library_changes, key=lambda x: x["type"]) - - for change_type, changes in grouped_changes: + type_key = "type" + source_commit_hash_key = "source_commit_hash" + subject_key = "subject" + library_changes.sort(key=lambda x: x[type_key]) + grouped_changes = itertools.groupby(library_changes, key=lambda x: x[type_key]) + + library_change_type_map = { + "feat": "Features", + "fix": "Bug Fixes", + "docs": "Documentation", + } + for library_change_type, library_changes in grouped_changes: # We only care about feat, fix, docs - adjusted_change_type = change_type.replace("!", "") - change_type_map = { - "feat": "Features", - "fix": "Bug Fixes", - "docs": "Documentation", - } - if adjusted_change_type in ["feat", "fix", "docs"]: - entry_parts.append(f"\n\n### {change_type_map[adjusted_change_type]}\n") - for change in changes: - commit_link = f"([{change['source_commit_hash']}]({repo_url}/commit/{change['source_commit_hash']}))" - entry_parts.append(f"* {change['subject']} {commit_link}") + adjusted_change_type = library_change_type.replace("!", "") + if adjusted_change_type in library_change_type_map: + entry_parts.append( + f"\n\n### {library_change_type_map[adjusted_change_type]}\n" + ) + for change in library_changes: + commit_link = f"([{change[source_commit_hash_key]}]({repo_url}/commit/{change[source_commit_hash_key]}))" + entry_parts.append(f"* {change[subject_key]} {commit_link}") new_entry_text = "\n".join(entry_parts) anchor_pattern = re.compile( @@ -697,16 +702,17 @@ def _update_changelog_for_library( be updated. """ - source_path = f"{repo}/packages/{package_name}/CHANGELOG.md" - output_path = f"{output}/packages/{package_name}/CHANGELOG.md" + relative_path = f"packages/{package_name}/CHANGELOG.md" + changelog_src = f"{repo}/{relative_path}" + changelog_dest = f"{output}/{relative_path}" updated_content = _process_changelog( - _read_text_file(source_path), + _read_text_file(changelog_src), library_changes, version, previous_version, package_name, ) - _write_text_file(output_path, updated_content) + _write_text_file(changelog_dest, updated_content) def handle_release_init( From 0acc398ea041451d4df4f3489e2e61435bf8ef2b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 9 Sep 2025 23:32:47 +0000 Subject: [PATCH 2/4] fix rebase issue --- .generator/cli.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.generator/cli.py b/.generator/cli.py index 6f2bb42d0dfb..f03c8ba0447c 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -762,14 +762,9 @@ def _process_changelog( library_changes.sort(key=lambda x: x[type_key]) grouped_changes = itertools.groupby(library_changes, key=lambda x: x[type_key]) - library_change_type_map = { - "feat": "Features", - "fix": "Bug Fixes", - "docs": "Documentation", - } for library_change_type, library_changes in grouped_changes: # We only care about feat, fix, docs - adjusted_change_type = change_type.replace("!", "") + adjusted_change_type = library_change_type.replace("!", "") change_type_map = { "feat": "Features", "fix": "Bug Fixes", @@ -777,7 +772,7 @@ def _process_changelog( } if adjusted_change_type in ["feat", "fix", "docs"]: entry_parts.append(f"\n\n### {change_type_map[adjusted_change_type]}\n") - for change in changes: + for change in library_changes: commit_link = f"([{change[source_commit_hash_key]}]({_REPO_URL}/commit/{change[source_commit_hash_key]}))" entry_parts.append(f"* {change[subject_key]} {commit_link}") From 6c8db64252e8debaa74600b3760151ad3da3f111 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 9 Sep 2025 23:38:40 +0000 Subject: [PATCH 3/4] fix rebase issue --- .generator/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.generator/cli.py b/.generator/cli.py index f03c8ba0447c..855a9bcc0141 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -770,7 +770,7 @@ def _process_changelog( "fix": "Bug Fixes", "docs": "Documentation", } - if adjusted_change_type in ["feat", "fix", "docs"]: + if adjusted_change_type in change_type_map: entry_parts.append(f"\n\n### {change_type_map[adjusted_change_type]}\n") for change in library_changes: commit_link = f"([{change[source_commit_hash_key]}]({_REPO_URL}/commit/{change[source_commit_hash_key]}))" From 2daa52fec56255e270afc03d6872aa691b721cb8 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 9 Sep 2025 23:39:18 +0000 Subject: [PATCH 4/4] fix rebase issue --- .generator/cli.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.generator/cli.py b/.generator/cli.py index 855a9bcc0141..1b0c350425ad 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -762,14 +762,14 @@ def _process_changelog( library_changes.sort(key=lambda x: x[type_key]) grouped_changes = itertools.groupby(library_changes, key=lambda x: x[type_key]) + change_type_map = { + "feat": "Features", + "fix": "Bug Fixes", + "docs": "Documentation", + } for library_change_type, library_changes in grouped_changes: # We only care about feat, fix, docs adjusted_change_type = library_change_type.replace("!", "") - change_type_map = { - "feat": "Features", - "fix": "Bug Fixes", - "docs": "Documentation", - } if adjusted_change_type in change_type_map: entry_parts.append(f"\n\n### {change_type_map[adjusted_change_type]}\n") for change in library_changes: