Skip to content

Fixing bug where comment added to multiline attribute was added as suffix#1434

Merged
oreflow merged 1 commit intomainfrom
cmd-comment-fix
Dec 30, 2025
Merged

Fixing bug where comment added to multiline attribute was added as suffix#1434
oreflow merged 1 commit intomainfrom
cmd-comment-fix

Conversation

@oreflow
Copy link
Collaborator

@oreflow oreflow commented Dec 30, 2025

  • Also implementing tests for cmdComment

#1073

@oreflow oreflow requested a review from a team as a code owner December 30, 2025 08:58
@oreflow oreflow requested review from vladmos and removed request for a team December 30, 2025 08:58
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @oreflow, 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 a specific bug in comment placement for multiline attributes, ensuring that comments are correctly associated with the attribute rather than being misplaced. It introduces a new utility to detect multiline expressions and includes comprehensive tests to validate the fix and prevent regressions in comment handling.

Highlights

  • Bug Fix: Resolved an issue where comments added to multiline attributes were incorrectly appended as suffixes instead of being placed before the attribute.
  • New Utility Function: Introduced a new IsMultiLine function in build/utils.go to accurately determine if an expression spans multiple lines, which is crucial for correct comment placement.
  • Enhanced Comment Handling: Updated the cmdComment function in edit/buildozer.go to leverage the new IsMultiLine function, ensuring comments are correctly positioned for both single-line and multiline attributes and list elements.
  • Expanded Test Coverage: Added a new test file build/utils_test.go for the IsMultiLine function and significantly expanded the test suite for cmdComment in edit/buildozer_test.go to cover various comment scenarios, including multiline attributes and list items.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 fixes a bug where comments on multiline attributes were incorrectly added as suffixes. The change introduces a new IsMultiLine utility function and uses it to correctly place comments before multiline attributes. The PR also commendably adds new tests for both the new utility and the cmdComment functionality.

I've found a potential issue with how the fix was applied when commenting on individual items within a list, which seems to contradict the behavior expected by one of the new tests. I've also noted a couple of minor improvements for the new test files to make them more robust and correct. Overall, this is a good change that improves commenting behavior.

@oreflow oreflow force-pushed the cmd-comment-fix branch 2 times, most recently from 4327b50 to fd6740e Compare December 30, 2025 09:04
…ffix

- Also implementing tests for cmdComment
@bazelbuild bazelbuild deleted a comment from gemini-code-assist bot Dec 30, 2025
@oreflow oreflow requested a review from ibsa21 December 30, 2025 09:09
@oreflow oreflow merged commit dc2c657 into main Dec 30, 2025
6 checks passed
@oreflow oreflow deleted the cmd-comment-fix branch December 30, 2025 10:07
oreflow added a commit that referenced this pull request Dec 31, 2025
Fixes breakage caused by #1434
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