Skip to content

Commit b511ec0

Browse files
authored
chore(librarian): Create package changelog if not present (#14963)
When adding a new API version to an existing library, the contents of the existing package level `CHANGELOG.md` file is removed. The issue is that a new changelog is created unconditionally here: https://github.com/googleapis/google-cloud-python/blob/c7696a668a405bdafee59a9341f6d04340d0c45e/.generator/cli.py#L295 As an example, the command below adds the client library code for `google/cloud/maintenance/api/v1` to an existing package [google-cloud-maintenance-api](https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-maintenance-api) ``` librarian generate -api=google/cloud/maintenance/api/v1 -library=google-cloud-maintenance-api ``` After running the command locally, see that the contents of this [CHANGELOG.md](https://raw.githubusercontent.com/googleapis/google-cloud-python/refs/heads/main/packages/google-cloud-maintenance-api/CHANGELOG.md) is gone. See below ``` (py392) partheniou@partheniou-vm-3:~/git/google-cloud-python$ git diff packages/google-cloud-maintenance-api/CHANGELOG.md diff --git a/packages/google-cloud-maintenance-api/CHANGELOG.md b/packages/google-cloud-maintenance-api/CHANGELOG.md index 6436543..d884ea3cedb 100644 --- a/packages/google-cloud-maintenance-api/CHANGELOG.md +++ b/packages/google-cloud-maintenance-api/CHANGELOG.md @@ -3,31 +3,3 @@ [PyPI History][1] [1]: https://pypi.org/project/google-cloud-maintenance-api/#history - -## [0.2.0](google-cloud-maintenance-api-v0.1.1...google-cloud-maintenance-api-v0.2.0) (2025-10-20) - - -### Features - -* Add support for Python 3.14 ([98ee71a](98ee71a)) - - -### Bug Fixes - -* Deprecate credentials_file argument ([98ee71a](98ee71a)) - -## [0.1.1](google-cloud-maintenance-api-v0.1.0...google-cloud-maintenance-api-v0.1.1) (2025-07-23) - - -### Documentation - -* Add missing comments for messages ([f955689](f955689)) - -## 0.1.0 (2025-06-23) ``` With the fix in this PR, a package level changelog will only be created if it is not present. An existing changelog will remain untouched.
1 parent c7696a6 commit b511ec0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.generator/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,12 @@ def handle_configure(
290290
)
291291
prepared_config = _prepare_new_library_config(new_library_config)
292292

293-
# Create a `CHANGELOG.md` and `docs/CHANGELOG.md` file for the new library
293+
is_mono_repo = _is_mono_repo(input)
294294
library_id = _get_library_id(prepared_config)
295-
_create_new_changelog_for_library(library_id, output)
295+
path_to_library = f"packages/{library_id}" if is_mono_repo else "."
296+
if not Path(f"{repo}/{path_to_library}").exists():
297+
# Create a `CHANGELOG.md` and `docs/CHANGELOG.md` file for the new library
298+
_create_new_changelog_for_library(library_id, output)
296299

297300
# Write the new library configuration to configure-response.json.
298301
_write_json_file(f"{librarian}/configure-response.json", prepared_config)

0 commit comments

Comments
 (0)