buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

should print formatting be 'source' compatible

Open lukesandberg opened this issue 6 years ago • 6 comments

$ buildozer 'print srcs' //some:target
glob(
    ["*.foo"],
    exclude = [
        "a.foo",
        "b.foo",
    ],
)

however, if i do the same with a simple srcs list

$ buildozer 'print srcs' //some/other:target
[a.foo b.foo]

i get no quotation marks and no commas.

I naively assumed expected the result of 'print' to be similar to the actual source code in the BUILD file

lukesandberg avatar Jan 07 '19 23:01 lukesandberg

deleting this condition https://github.com/bazelbuild/buildtools/blob/master/edit/buildozer.go#L310

fixes this issue, @laurentlb thought this might break users.

lukesandberg avatar Jan 07 '19 23:01 lukesandberg

This effectively makes the output not parseable since spaces in the attributes are indistinguishable from the separators - any chance an argument could be added to print the output with commas & quotes to not break existing users?

@vladmos I could try to hack a PR together if you had a preferred approach here?

leos avatar Jun 27 '20 15:06 leos

Perhaps we can try to change the current behavior and I'll try to estimate how many existing users are broken by that, at least internally. Then we can decide if we need a special flag.

@leos If you want to send a PR please do it.

vladmos avatar Aug 05 '20 12:08 vladmos

Thanks @vladmos - is there a guide/wiki on setting up a dev env and running tests for buildozer?

leos avatar Aug 05 '20 15:08 leos

Just running bazel test //... in the repository root should be enough.

vladmos avatar Aug 06 '20 10:08 vladmos

+1 to the list of users broken by this behavior (we use Bazel in googleapis org and we sometimes have values with spaces which all get screwed up). I was thinking, do you folks look into changing the existing behavior of print command (possibly breaking users), or maybe have a better command - call it print_json, or print_list, or whatever, that will do the right machine readable thing? Happy to send a PR.

alexander-fenster avatar Feb 24 '21 02:02 alexander-fenster