buildozer: 'print label' interacts poorly with ellipsis
For example, in the buildtools repo:
$ bazel-bin/buildozer/buildozer '//edit/...:*' 'print label
//edit/...:go_default_library
//edit/...:go_default_test
The output if you try to use ellipsis with the root directory is even weirder:
bazel-bin/buildozer/buildozer '...:*' "print label"
//...:go_default_library
//...:tests
//...:go_default_library
//...:go_default_library
//...:generatetables
//...:copy_and_fix
//...:go_default_library
//...:go_default_library
//...:go_default_test
//...:go_default_library
//...:go_default_library
//...:buildozer
//...:go_default_library
//...:go_default_test
//...:go_default_library
//...:copy_and_fix
//...:go_default_library
//...:copy_and_fix
//...:go_default_library
//...:go_default_library
//...:unused_deps
//...:generateTablesFile
//...:go_default_library
//...:go_default_library
//...:go_default_test
//...:buildifier
//...:go_default_library
//...:go_default_test
It looks like there is no code to adjust the output label to account for the actual path in use. We just preserve the ellipsis bit in the input label.
(By the way, this doesn't seem to be caused by fe4721cc0c3a73b2609a3285316e06906e8b4b8e. If you rename BUILD.bazel files to BUILD and check out eaf5ad1d131ea7adf07b958289aea8f80c5ff62b (the preceding commit), this issue still repros.)
Just ran into this today, it breaks a workflow I was hoping to use.
How much active development happens on buildozer these days? Should I expect a fix soon? If I submit a PR is it likely to get reviewed / merged? Do other people have workarounds for this issue?
Yes, we'll review a PR for this bug.
I believe the alternative is to avoid ... and pass explicitly the file of BUILD files (possibly using the find command on Unix).
Ah, perfect.
Running find . -name BUILD.bazel | <sed and grep foo> to generate a bunch of //explicit/package/paths:* did the trick for me. Thanks!
@sarum90 are you still going to work on this bug or should I create a fix?
Ah, apologies, nope. With the work-around of explicitly passing BUILD files on the command line I was no longer blocked by this, and never wound up working on it.
Do not expect any PRs from me.
I just ran into something like this. The result wasn't exactly identical. Instead the package was dropped when using ellipsis:
$ buildozer 'print label' //some/path/to/package/...:%custom_rule
//:custom_target
$ buildozer 'print label' //some/path/to/package/BUILD:%custom_rule
//some/path/to/package:custom_target
Strangely, this only happened on one package of hundreds, and I haven't been able to identify why that one was impacted.