fix: Support additional api paths for an existing library#2666
Conversation
0b53d46 to
2052cc2
Compare
2052cc2 to
9d4a596
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2666 +/- ##
==========================================
+ Coverage 85.68% 87.40% +1.71%
==========================================
Files 108 108
Lines 11165 9433 -1732
==========================================
- Hits 9567 8245 -1322
+ Misses 1260 847 -413
- Partials 338 341 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly extends the functionality to support adding new API paths to existing libraries. The logic in needsConfigure is updated, and a new helper function addAPIToLibrary is introduced to handle the state modification, which is a good approach. The accompanying tests cover most of the new logic. I've provided a couple of suggestions to improve maintainability by reusing existing helper functions and to enhance test coverage by adding a missing test case.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for adding new API paths to existing libraries. The core logic is updated in the needsConfigure function to correctly trigger the configuration process when a new API is specified for an existing library. The state modification logic has been cleanly refactored into a new addAPIToLibrary function, improving modularity. Comprehensive unit tests have been added for both addAPIToLibrary and the updated needsConfigure, ensuring the new functionality is well-covered. The changes are well-structured, correct, and improve the maintainability of the codebase. I have no issues to report.
| // addAPIToLibrary adds a new API to a library in the state. | ||
| // If the library does not exist, it creates a new one. | ||
| // If the API already exists in the library, do nothing. | ||
| func addAPIToLibrary(state *config.LibrarianState, libraryID, apiPath string) { |
There was a problem hiding this comment.
Should this be a method on the config.LibrarianState object? It seems a little odd that a random librarian package function is mutating the internal state of this struct.
…2676) As a follow up to #2666, this PR adds another test case to check that a new API path can be added to an existing library in state.yaml. The test case added in #2666 did not have any API paths in the existing library. See the snippet below where there is no API path in the existing library. https://github.com/googleapis/librarian/blob/50046f559ee7cdcc4115ae790c7218a09c7fd9ae/internal/librarian/generate_command_test.go#L1572-L1584 For completeness and to avoid regressions, we should also test that new paths can be added to an existing library which already has API paths. This PR adds the missing test case. --------- Signed-off-by: Anthonios Partheniou <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: not available Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest <details><summary>librarian: 1.0.0</summary> ## [1.0.0](v0.5.0...v1.0.0) (2025-11-06) ### Features * Remove `..._gax` dependency (#2713) ([01675b7](01675b72)) * add context to Librarian PRs (#2698) ([0523329](0523329a)) * add a package comment linter (#2712) ([1bd3e32](1bd3e32e)) * generate pom.xml files (#2682) ([50b95f2](50b95f20)) * add test-container test logic (#2656) ([514cf7e](514cf7e5)) * improve rust-publish logging (#2671) ([585ed50](585ed50b)) * write a timing log at the end of update-image (#2771) ([5fc9e3b](5fc9e3b6)) * migrate Java container from sdk-platform-java (#2670) ([69ac47f](69ac47fd)) * switch to original head after running update-image (#2696) ([7a3e404](7a3e404a)) * format bulk commit from other sources in release notes (#2665) ([7c52da2](7c52da2b)) * enable multi-version API generation (#2699) ([86c5250](86c52507)) * release stage to update pom.xml files (#2772) ([be56755](be567550)) * use proto presence info to generate null-safe code (#2726) ([e36fb81](e36fb81a)) * Base messages in google_cloud_protobuf (#2660) ([e607ea6](e607ea63)) ### Bug Fixes * retry Github 503 requests up to 3 times (#2650) ([09468fa](09468faf)) * Changed docs to ConfigurationException (#2697) ([0950c1e](0950c1e3)) * fix the reference to the old "librariangen" folder (#2677) ([09dc53f](09dc53fe)) * run godoclint via golangci-lint (#2751) ([264a6a0](264a6a0e)) * pass context as the first argument (#2769) ([298a3bd](298a3bd8)) * Move HTTP client creation to `_gax` (#2672) ([4968d63](4968d63d)) * deduplicate bulk commits (#2758) ([4dfae9a](4dfae9ae)) * Support additional api paths for an existing library (#2666) ([50046f5](50046f55)) * remove stray TODO (#2748) ([5072f0e](5072f0e0)) * omit status field when empty (#2654) ([572ae4f](572ae4f3)) * use T.Context in tests (#2768) ([7e7cd2d](7e7cd2dd)) * wrap error to provide more context for commitAndPush (#2767) ([a2a41a4](a2a41a4a)) * use t.Fatal in tests for proper failure handling (#2759) ([cdabb28](cdabb287)) * enforce removal before copying library files (#2765) ([d5ac6c8](d5ac6c87)) * change log level to debug (#2798) ([f042d0b](f042d0bd)) * change path to `doc.go` in docgen test (#2700) ([fd6bae4](fd6bae40)) ### Documentation * use consistent library id in flags and examples (#2770) ([87a1005](87a10056)) </details>
Fixes #2651