Skip to content

Add command that updates existing attributes with a select#1460

Open
kisabaka wants to merge 2 commits intobazelbuild:mainfrom
kisabaka:feature-add-select
Open

Add command that updates existing attributes with a select#1460
kisabaka wants to merge 2 commits intobazelbuild:mainfrom
kisabaka:feature-add-select

Conversation

@kisabaka
Copy link
Copy Markdown

@kisabaka kisabaka commented Mar 30, 2026

Buildtools PR checklist

  • The code in this PR is covered by unit/integration tests.
  • I have tested these changes and provide testing instructions below.
  • I have either responded to, or resolved all Gemini comments on the PR.
  • I have read Google Eng Practices on Small Changes, this PR either follows these guidelines or the description provides reasoning for why they can not be followed.

Description

Adds a command to update attributes with a select.

buildozer 'add_select deps @platforms//os:linux :linux_bar' :foo

E.g
Before:

cc_library(
  name = "foo",
  deps = [
    ":bar",
  ]
)

After:

cc_library(
  name = "foo",
  deps = [
    ":bar",
  ] + select({
    "@platforms//os:linux": [":linux_foo"],
    "//conditions:default": [],
  }),
)

(optional) These changes were tested using the following steps

Steps to reproduce / test the PR changes (if anything besides unit tests).
bazel test //...
go test ./edit/...

@kisabaka kisabaka requested a review from a team as a code owner March 30, 2026 11:56
@kisabaka kisabaka requested review from vladmos and removed request for a team March 30, 2026 11:56
Copy link
Copy Markdown
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 introduces the add_select command to buildozer, enabling the addition or update of values within select expressions for both list and scalar attributes. The implementation includes helper functions to manage existing select blocks, handle concatenation with plain lists, and ensure default conditions are present. Feedback was provided to maintain consistency in list sorting by utilizing the attributeMustNotBeSorted check when adding values to list attributes.

Comment thread edit/buildozer.go Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant