New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for buildifier style in BUILD files, or support running an auto-format binary after pants tailor
#20836
Comments
I don't know if this works as any of the tailor stuff I run is pretty basic, but would something like this work for you? I'm not entirely sure if
As a fallback, if that didn't work, then maybe something like https://www.pantsbuild.org/2.20/reference/subsystems/buildifier |
Yes, those work, and are a way to avoid manually running |
I'll concede, I'm a bit confused as to your workflow now.
How are you running |
Yes, we're running it manually. I'd prefer to just run one command, otherwise we need to mention to everyone the "proper" way to create new build files, which is not just to run |
So, in That's a very common paradigm, so If you wanted to "simplify" it, you could create an alias to do that for you (https://www.pantsbuild.org/2.20/reference/subsystems/cli#alias). [cli.alias]
ftailor = "tailor fmt" |
Thanks, I agree that's better than I had originally come up with. I still think, though, that automatically formatting (if Pants knows how) anything Pants generates would be a completely reasonable thing to implement, and would help simplify this. Ideally, Pants should get things right without workarounds, even simple ones. |
I agree with your point that this could be better: pants is writing new data to file that it (a) knows how to reformat, and (b) knows should be reformatted. Would be a nice quality-of-life improvement to do the reformatting automatically! It looks like this is the rule that does the editing, including reading the existing contents: pants/src/python/pants/core/goals/tailor.py Lines 532 to 573 in 0d35991
I'm not exactly sure how we'd apply the appropriate build file formatting rules likely something involving rules from https://github.com/pantsbuild/pants/blob/0d35991d0814fa4f45ce504933d143525898e653/src/python/pants/core/goals/update_build_files.py |
Is your feature request related to a problem? Please describe.
Our organization wants to have a consistent BUILD style, so we are using bazel's buildifier binary, which works well. However, by default,
pants tailor
creates BUILD files that do not conform to this binary, so now users have to runpants tailor
and then manually go and runbuildifier
.Describe the solution you'd like
Two good solutions I can think of:
tailor
option to supportbuildifier
style, or any other popular style.tailor
option to run an arbitrary program on the generated files.Describe alternatives you've considered
We're living the alternative, which is to just do things manually. It could be better.
Additional context
None
The text was updated successfully, but these errors were encountered: