Skip to content

Commit a999c67

Browse files
authored
chore(librarian): include body in changelog (googleapis#14536)
This PR resolves the issue where information could be missing in the `CHANGELOG.md` file in the rare case that the conventional commit content for a given change is included in both the `subject` and `body` of the `changes` section of `release-init-request.json`. See https://github.com/googleapis/librarian/blob/main/doc/language-onboarding.md#release-init to read more on the `changes` section of `release-init-request.json`
1 parent 0f91e38 commit a999c67

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.generator/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ def _process_changelog(
933933
type_key = "type"
934934
source_commit_hash_key = "source_commit_hash"
935935
subject_key = "subject"
936+
body_key = "body"
936937
library_changes.sort(key=lambda x: x[type_key])
937938
grouped_changes = itertools.groupby(library_changes, key=lambda x: x[type_key])
938939

@@ -948,7 +949,7 @@ def _process_changelog(
948949
entry_parts.append(f"\n\n### {change_type_map[adjusted_change_type]}\n")
949950
for change in library_changes:
950951
commit_link = f"([{change[source_commit_hash_key]}]({_REPO_URL}/commit/{change[source_commit_hash_key]}))"
951-
entry_parts.append(f"* {change[subject_key]} {commit_link}")
952+
entry_parts.append(f"* {change[subject_key]} {change[body_key]} {commit_link}")
952953

953954
new_entry_text = "\n".join(entry_parts)
954955
anchor_pattern = re.compile(

.generator/test_cli.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
{
8282
"type": "fix",
8383
"subject": "some fix",
84-
"body": "",
84+
"body": "some body",
8585
"piper_cl_number": "786353208",
8686
"source_commit_hash": "1231532e7d19c8d71709ec3b502e5d81340fb661",
8787
},
@@ -304,7 +304,10 @@ def test_get_new_library_config_not_found():
304304
"""Tests that an empty dictionary is returned when no new library is found."""
305305
request_data = {
306306
"libraries": [
307-
{"id": "existing-library", "apis": [{"path": "path/v1", "status": "existing"}]},
307+
{
308+
"id": "existing-library",
309+
"apis": [{"path": "path/v1", "status": "existing"}],
310+
},
308311
]
309312
}
310313
config = _get_new_library_config(request_data)
@@ -333,7 +336,10 @@ def test_prepare_new_library_config():
333336
assert "status" not in prepared_config["apis"][0]
334337
# Check that defaults are added
335338
assert prepared_config["source_roots"] == ["packages/google-cloud-language"]
336-
assert "packages/google-cloud-language/CHANGELOG.md" in prepared_config["preserve_regex"]
339+
assert (
340+
"packages/google-cloud-language/CHANGELOG.md"
341+
in prepared_config["preserve_regex"]
342+
)
337343
assert prepared_config["remove_regex"] == ["packages/google-cloud-language"]
338344
assert prepared_config["tag_format"] == "{{id}}-v{{version}}"
339345

@@ -957,12 +963,12 @@ def test_process_changelog_success():
957963
expected_result = f"""# Changelog\n[PyPI History][1]\n[1]: https://pypi.org/project/google-cloud-language/#history\n
958964
## [1.2.3](https://github.com/googleapis/google-cloud-python/compare/google-cloud-language-v1.2.2...google-cloud-language-v1.2.3) ({current_date})\n\n
959965
### Documentation\n
960-
* fix typo in BranchRule comment ([9461532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/9461532e7d19c8d71709ec3b502e5d81340fb661))\n\n
966+
* fix typo in BranchRule comment ([9461532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/9461532e7d19c8d71709ec3b502e5d81340fb661))\n\n
961967
### Features\n
962-
* add new UpdateRepository API ([9461532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/9461532e7d19c8d71709ec3b502e5d81340fb661))\n\n
968+
* add new UpdateRepository API This adds the ability to update a repository's properties. ([9461532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/9461532e7d19c8d71709ec3b502e5d81340fb661))\n\n
963969
### Bug Fixes\n
964-
* some fix ([1231532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/1231532e7d19c8d71709ec3b502e5d81340fb661))
965-
* another fix ([1241532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/1241532e7d19c8d71709ec3b502e5d81340fb661))\n
970+
* some fix some body ([1231532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/1231532e7d19c8d71709ec3b502e5d81340fb661))
971+
* another fix ([1241532e7d19c8d71709ec3b502e5d81340fb661](https://github.com/googleapis/google-cloud-python/commit/1241532e7d19c8d71709ec3b502e5d81340fb661))\n
966972
## [1.2.2](https://github.com/googleapis/google-cloud-python/compare/google-cloud-language-v1.2.1...google-cloud-language-v1.2.2) (2025-06-11)"""
967973
version = "1.2.3"
968974
previous_version = "1.2.2"

0 commit comments

Comments
 (0)