Skip to content
Merged
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
40 changes: 22 additions & 18 deletions .generator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,22 +756,25 @@ def _process_changelog(
)

# 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])

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"]:
adjusted_change_type = library_change_type.replace("!", "")
if adjusted_change_type in change_type_map:
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}")
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(
Expand Down Expand Up @@ -810,16 +813,17 @@ def _update_changelog_for_library(
be updated.
"""

source_path = f"{repo}/packages/{library_id}/CHANGELOG.md"
output_path = f"{output}/packages/{library_id}/CHANGELOG.md"
relative_path = f"packages/{library_id}/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,
library_id,
)
_write_text_file(output_path, updated_content)
_write_text_file(changelog_dest, updated_content)


def handle_release_init(
Expand Down
Loading