Skip to content

refactor(internal/librarian/java): accept file path in extractTitle - #6573

Merged
yangyzs merged 3 commits into
googleapis:mainfrom
yangyzs:refactor/java-extract-title
Jun 29, 2026
Merged

yangyzs merged 3 commits into
googleapis:mainfrom
yangyzs:refactor/java-extract-title

Conversation

@yangyzs

@yangyzs yangyzs commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Accept file path in extractTitle to read file content from disk directly. Update unit tests to use t.TempDir().

Follow-up to #6546

Accept file path in `extractTitle` to read file content from disk directly. Update unit tests to use `t.TempDir()`.

Follow-up to googleapis#6546
@yangyzs
yangyzs requested a review from a team as a code owner June 29, 2026 18:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/librarian/java/readme.go Resolved
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]>
@yangyzs
yangyzs requested a review from JoeWang1127 June 29, 2026 18:40
@yangyzs
yangyzs merged commit a71db8e into googleapis:main Jun 29, 2026
31 checks passed
@yangyzs
yangyzs deleted the refactor/java-extract-title branch June 29, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants