Repository navigation
refactor(internal/librarian/java): accept file path in extractTitle - #6573
Merged
Merged
Conversation
Accept file path in `extractTitle` to read file content from disk directly. Update unit tests to use `t.TempDir()`. Follow-up to googleapis#6546
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the extractTitle function in internal/librarian/java/readme.go to accept a file path and read the file from disk, rather than accepting the file content directly as a string. The corresponding tests in readme_test.go have been updated to write test content to temporary files. The review feedback suggests optimizing extractTitle by using bytes.Contains directly on the byte slice before converting it to a string, which avoids unnecessary memory allocations when the metadata marker is missing.
Use bytes.Contains on read byte slice before converting to string to avoid unnecessary memory allocations on files without sample metadata. Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: yangyzs <[email protected]>
JoeWang1127
approved these changes
Jun 29, 2026
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.
Accept file path in extractTitle to read file content from disk directly. Update unit tests to use t.TempDir().
Follow-up to #6546