Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buildozer add command does not respect tables or add_tables #1320

Open
chowesasana opened this issue Dec 27, 2024 · 0 comments
Open

Buildozer add command does not respect tables or add_tables #1320

chowesasana opened this issue Dec 27, 2024 · 0 comments

Comments

@chowesasana
Copy link

chowesasana commented Dec 27, 2024

Running buildozer add with a list argument (ex: buildozer add foo c b a) will always sort the list before adding, regardless of any tables or add_tables you may pass it.

I believe this is because the AddValueToListAttribute function sorts on everything other than args. https://github.com/bazelbuild/buildtools/blob/main/edit/edit.go#L826

Ideally buildozer would respect the same tables that buildifier would, or perhaps it would be better to defer all of the sorting to buildifier?

Buildozer test case:

function test_unsorted_other_attr() {
  in='go_library(
    name = "edit",
    deps = [],
    other_attr = []
)'
  run "$in" 'add other_attr z y x' '//pkg:edit'
  assert_equals 'go_library(
    name = "edit",
    deps = [
    ],
    other_attr = [
      "z",
      "y",
      "x",
    ]
)'
}
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

No branches or pull requests

1 participant