buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildozer should be able to take a list of file paths as input rather than package specs

Open aiuto opened this issue 5 years ago • 3 comments

Context: Imagine a system where BUILD files are not part of the committed source, but aggregated from checked in fragments and generated ones. A large change over the code base would need to identify the fragment files to change, rather than the targets in the generated BUILD files.

aiuto avatar Sep 13 '18 15:09 aiuto

To clarify the intent - this was so someone doing an incompatible migration can provide a single buildozer script that fixes all targets in a built tree.

A releated idea along the same lines"

buildozer -f changes.txt

changes.txt:

if , but limited to targets in this file { buildozer commands to apply } ...

Sort of a mix of find | grep | xargs buildozer ...

A *nix user could do script this up, but it is harder to do on Windows. Having a single tool which can identify files to change and change them (and was portable) would make it much easier for rule owners to write single script fixes.

aiuto avatar Feb 04 '19 19:02 aiuto

Ah... I see it is time for my repeat request on this one. I am doing a change of about 20K BUILD files. I know the ones I want to touch, and our monorepo is large, so I don't want to do a global ... for the change. So, while I can write

sed -e  's@/BUILD@:*@' targeted_files.txt | xargs buildifier 'command'

it would be a lot easier and portable to windows to write

buildifier -cmds <command file> -files targeted_files.txt

Actually, I snuck in another request there. I want to specify a list of buildifier commands in a file.

aiuto avatar Jul 30 '21 01:07 aiuto

Buildozer already accepts a list of paths as input. But that will refer to the package declaration. Changing the behavior is a breaking change.

I don't think asking for :* is too much. If you don't want to use sed, you can put the input in a file and use search and replace.

With Buildozer, you can put all the commands/inputs in a file: https://github.com/bazelbuild/buildtools/blob/master/buildozer/README.md#do-multiple-changes-at-once

laurentlb avatar Jul 30 '21 08:07 laurentlb