feat(internal/librarian/java): add entries to versions.txt for new modules#4967
Open
perashanid wants to merge 2 commits intogoogleapis:mainfrom
Open
feat(internal/librarian/java): add entries to versions.txt for new modules#4967perashanid wants to merge 2 commits intogoogleapis:mainfrom
perashanid wants to merge 2 commits intogoogleapis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces logic to automatically update the versions.txt file when new Java modules are generated. It includes a new updateVersionsFile function and corresponding unit tests. The review feedback suggests simplifying the file-reading logic to avoid redundant system calls and improving test assertions by using cmp.Diff to align with the project's style guide.
- Simplify file reading by using os.ReadFile directly and checking os.IsNotExist - Use cmp.Diff for test assertions following project style guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds functionality to automatically update versions.txt when new Java modules are generated. This is needed during migration when release-please is still in use.
Changes Made:
Modified generatePomsIfMissing to track newly created modules and call updateVersionsFile after generating POMs
Added updateVersionsFile function that appends entries to versions.txt for new modules
The function handles creating the file if it doesn't exist, appending to existing content, and avoiding duplicate entries
Format used: module-name:0.0.0:version-SNAPSHOT where 0.0.0 is the initial released version for new modules
Technical Implementation:
When new proto-, grpc-, or gapic client modules are generated, their artifact IDs are collected
The updateVersionsFile function reads the existing versions.txt to avoid duplicates
New entries are appended with format: module:0.0.0:library-version-SNAPSHOT
The file is created in the repository root (parent directory of the library directory)
Testing:
Added comprehensive test coverage in TestUpdateVersionsFile with scenarios for:
All existing pom-related tests pass
No linting or diagnostic issues
Fixes #4927