buildtools
buildtools copied to clipboard
buildozer should be able to take a list of file paths as input rather than package specs
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.
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
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.
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.
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