-
Notifications
You must be signed in to change notification settings - Fork 6
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
Only write files on change. #96
Only write files on change. #96
Conversation
When formatting files, genemichaels always writes the formatted file to disk which modifies the file timestamp. This is problematic for tools that detect whether a file has been reformatted or not. This commit changes the behavior by comparing the source against the formatted output and only writing to disk if they are different. See: andrewbaxter#95
When formatting rust files with `genemichaels`, the timestamp of the file is always modified whether or not the file was changed. This is problematic for detecting whether a file has been reformatted or not, such as when using tools such as `pre-commit`, `treefmt`, and `treefmt-nix`. See the following: andrewbaxter/genemichaels#95 andrewbaxter/genemichaels#96 numtide/treefmt-nix#277
Oh fantastic! Yeah, we shouldn't have been always writing. Thanks for this! |
Ah, that test was something I had for debug dumping output, I should get rid of that. |
Released as |
Do you mean this test that has been failing since 0.5.7? I was going to ask about that since I'd like to add the latest to nixpkgs but stopped at 0.5.7 since the tests after that started failing. See NixOS/nixpkgs#363473 |
Oh yeah, that one! Sorry, didn't realize it was causing problems externally. I'll get rid of it now. |
Okay as of |
Not a problem. I thought it was part of a developing test for the new macros crate. |
When formatting files, genemichaels always writes the formatted file to disk which modifies the file timestamp. This is problematic for tools that detect whether a file has been reformatted or not.
This commit changes the behavior by comparing the source against the formatted output and only writing to disk if they are different.
Fixes #95
I agree that when the request is merged I assign the copyright of the request to the repository owner.