fix(core): normalize line endings in diff context snippets - #29132
fix(core): normalize line endings in diff context snippets#29132mikemikimike wants to merge 2 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where inconsistent line endings caused incorrect diff context generation. By normalizing line endings to LF before processing, the tool now correctly identifies logical changes without being affected by platform-specific newline characters. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
🛑 Action Required: Evaluation ApprovalSteering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged. Maintainers:
Once approved, the evaluation results will be posted here automatically. |
There was a problem hiding this comment.
Code Review
This pull request normalizes line endings to \n in diff-utils.ts before performing line diffing to prevent CRLF differences from being flagged as changes, and adds a corresponding unit test. The reviewer pointed out a potential inconsistency where normalizedNew is normalized to \n but newLines is still split using /\r?\n/ on the original content, which could lead to mismatched line counts or out-of-bounds errors. The reviewer suggested splitting normalizedNew by \n instead.
|
Updated the fix based on review feedback.
Local validation:
The broader Core suite was also exercised in Docker; its remaining environment-sensitive failures were isolated to sandbox namespace availability before |
fee11de to
871dc21
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the diff utility functions in packages/core/src/tools/diff-utils.ts to normalize line endings (CRLF and CR to LF) before computing line differences and splitting the content. This ensures that changing only the line-ending style does not incorrectly trigger diffs. Corresponding unit tests have been added to packages/core/src/tools/diff-utils.test.ts to verify CRLF and CR line-ending handling. There are no review comments, so I have no feedback to provide.
|
当前 head 已落实该建议:newLines 改为基于 normalizedNew.split('\n'),并补充 standalone CR 回归测试。关闭此旧线程。 |
Summary
Fixes #29130
Testing
npm run test:cinpm run typecheck --workspace @google/gemini-cli-corenpm exec prettier -- --check packages/core/src/tools/diff-utils.ts packages/core/src/tools/diff-utils.test.tsnpm exec eslint packages/core/src/tools/diff-utils.ts packages/core/src/tools/diff-utils.test.tsgit diff --check