Is there any way to run `update-build-files` on a ...
# general
c
Is there any way to run
update-build-files
on a subset of files? I want to run it in a pre-commit hook as a formatter, but having it run over the entirety of the repository causes commits to be extremely slow. From https://www.pantsbuild.org/docs/reference-update-build-files, I see:
This goal is run without arguments. It will run over all BUILD files in your project.
b
So it looks like in Pants 2.14 you can (and are actually forced) to use arguments. You might try it and see if it works with your Pants version today.
Otherwise, you might get clever, and pass
--pants-ignore="+['...', '...']"
to tell pants to "ignore" certain dirs. during the command. YMMV on if that works
c
The following command seems to still run on all files as of Pants 2.11 😞
Copy code
./pants --changed-since=origin/master update-build-files
b
Ah yeah you can probably get really clever by running some shell command to revert changes to
BUILD
files that werent changed in this branch 🤷‍♂️
But you mention its slow, so that band-aid isn't gonna help with speed
w
How many files and directories are there in your project? I'm assuming it'll glob through, but isn't it only acting on a single file per directory (at most?). I'm more surprised it's slow, than anything else
c
My codebase is extremely large—it’s the codebase for my entire company, and we have a monorepo
🤯 1
h
This was fixed in 2.13 as a flagship feature 🙂
./pants --changed-since=HEAD update-build-files
does what you would expect, and then you use normal CLI args like
./pants update-build-files ::
or
./pants update-build-files dir1
release blog will happen in a few weeks describing the improvements. in the meantime, see https://github.com/pantsbuild/pants/pull/15816
c
Great, thanks so much! Very excited for this
❤️ 1