From 849778d1d48efc073ba12711197bd26709ee72b3 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 1 Oct 2025 18:34:45 +0000 Subject: [PATCH 1/2] chore(librarian): fix generation for google-cloud-common --- .generator/cli.py | 7 +++++-- .librarian/state.yaml | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.generator/cli.py b/.generator/cli.py index c4c2fe4c5bed..0bb844fd1772 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -694,9 +694,12 @@ def _get_staging_child_directory(api_path: str, is_proto_only_library: bool) -> version_candidate = api_path.split("/")[-1] if version_candidate.startswith("v") and not is_proto_only_library: return version_candidate - else: - # Fallback for non-'v' version segment + elif is_proto_only_library: + # Fallback for non-'v' version segment for proto-only library return f"{os.path.basename(api_path)}-py/{api_path}" + else: + # Fallback for non-'v' version segment for GAPIC + return f"{os.path.basename(api_path)}-py" def _stage_proto_only_library( diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 256b364b7607..8b67bca9500c 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -1569,6 +1569,7 @@ libraries: - scripts/client-post-processing - samples/snippets/README.rst - tests/system + - tests/unit/gapic/common/test_common.py remove_regex: - packages/google-cloud-common tag_format: '{id}-v{version}' From 943ce79a51cb1364f6ae568c843a5880e0e564a8 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 1 Oct 2025 19:13:14 +0000 Subject: [PATCH 2/2] add test --- .generator/test_cli.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.generator/test_cli.py b/.generator/test_cli.py index 1a9b8e934759..cd5d11bb7e21 100644 --- a/.generator/test_cli.py +++ b/.generator/test_cli.py @@ -1357,7 +1357,7 @@ def test_verify_library_namespace_error_no_gapic_file(mocker, mock_path_class): mock_path_class.assert_called_once_with("repo/packages/my-lib") -def test_get_staging_child_directory_gapic(): +def test_get_staging_child_directory_gapic_versioned(): """ Tests the behavior for GAPIC clients with standard 'v' prefix versioning. Should return only the version segment (e.g., 'v1'). @@ -1367,6 +1367,15 @@ def test_get_staging_child_directory_gapic(): expected = "v1" assert _get_staging_child_directory(api_path, False) == expected +def test_get_staging_child_directory_gapic_non_versioned(): + """ + Tests the behavior for GAPIC clients with no standard 'v' prefix versioning. + Should return library-py + """ + api_path = "google/cloud/language" + expected = "language-py" + assert _get_staging_child_directory(api_path, False) == expected + def test_get_staging_child_directory_proto_only(): """