buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildozer: 'print label' interacts poorly with ellipsis

Open swolchok opened this issue 8 years ago • 6 comments

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.)

swolchok avatar Jun 26 '17 22:06 swolchok

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?

sarum90 avatar Oct 30 '18 15:10 sarum90

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).

laurentlb avatar Oct 30 '18 16:10 laurentlb

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 avatar Oct 30 '18 16:10 sarum90

@sarum90 are you still going to work on this bug or should I create a fix?

vladmos avatar Dec 03 '18 18:12 vladmos

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.

sarum90 avatar Dec 03 '18 19:12 sarum90

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.

dfreese avatar Jan 15 '25 00:01 dfreese