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/.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(): """ 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}'