proud-dentist-22844
06/16/2022, 3:33 AMfmt
tool adds a new file? Should that be reported in the list of changed files?
Pants 2.12 shows the files that fmt changed, but the changed list only includes files that were present in both input and output digests.
I dove into the code to figure out what does the diff.
This is where the diff is displayed:
https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/goals/fmt.py#L116-L119
And this is where the actual diff happens, populating the list of changed_files
:
https://github.com/pantsbuild/pants/blob/main/src/rust/engine/fs/src/directory.rs#L599-L605
I believe that rust code only adds files to changed_files
if the file is in both ours
and theirs
during diff... but I don't understand some of the syntax of rust, so I'm not sure.proud-dentist-22844
06/16/2022, 3:41 AMour_unique_files
and their_unique_files
. so only the python bit needs to change.hundreds-father-404
06/16/2022, 3:42 AMproud-dentist-22844
06/16/2022, 3:51 AMdist/codegen
and so that some schemas/specs (that get checked in) get auto-generated whenever their python deps change (without requiring manually running some command beyond the standard goals that people will be doing regularly).proud-dentist-22844
06/16/2022, 3:53 AMproud-dentist-22844
06/16/2022, 4:03 AMlint
targets in the old Makefile (that I want to eliminate) ensure that these schemas/specs were regenerated if needed. If regeneration would change the files, then lint fails. So, as I'm translating that to pants, I'm making a formatter that generates those files. That formatter does double duty as a linter to allow me to replace those old Makefile targets.proud-dentist-22844
06/16/2022, 4:09 AMbitter-ability-32190
06/16/2022, 11:37 AMbitter-ability-32190
06/16/2022, 11:37 AMproud-dentist-22844
06/16/2022, 1:47 PMfix
would make more sense. Using fmt
for this feels wrong, but I don't want anyone to have to remember to extra commands if it can be avoided.proud-dentist-22844
06/16/2022, 1:48 PMoutput_directory
instead of output_files
to ensure that all generated files get captured. 🙂bitter-ability-32190
06/16/2022, 1:48 PMfmt
to fix
, and then we'll add a style-only
flag to it if you just want style.
The gist is our tools do more than format (like your case), but semantic changes aren't always welcome (consider running fix
on save, and it removes an import you just added, but havent used yet)proud-dentist-22844
06/16/2022, 1:51 PM