-
Notifications
You must be signed in to change notification settings - Fork 80
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
Validate/dry-run mode #212
Comments
Thanks for the idea. |
I'm not using Gradle - Bazel on GitLab CI. I can do something to run ktfmt over the whole repo, but building something more fine-grained by generating actual test targets would be much more convenient. Glad to see that it's something you'd be happy with, I don't have time to do that any time soon either, but if I have a free Sunday afternoon... :-) |
Can you elaborate? |
Sure, happy to elaborate - I don't have any Java so I don't run google-java-format. But I do run ktlint, and hoped I could do something similar. Basically, for every |
As a side note, ktfmt-gradle will also benefit form this. Currently I had to manually diff the ktfmt output with the original source file to understand if there was a violation or not (in order to support a |
Summary: In --dry-run mode, ktfmt will print the file paths of files that need formatting but will not change the file contents. Also added the option to exit the program with code `1` if any changes are needed rather than just if any errors happened. These changes are in alignment with google-java-format's identical options (see google/google-java-format#106). Usage: --dry-run or -n Prints the paths of the files whose contents would change if the formatter were run normally. --set-exit-if-changed Return exit code 1 if there are any formatting changes made (or detected if running in dry mode). Reviewed By: cgrushko Differential Revision: D31286652 fbshipit-source-id: c89fb72a1411766b81c28eba66614df78b0fea0a
This is now fixed in main, will release a new version on Monday or Tuesday. |
Matching google-java-format's google/google-java-format/issues/105 and google/google-java-format/pull/106 - it would be nice to have a dry-run mode that would show which files would be changed. Context: a CI task checking that the files are properly formatted.
google-java-format does this with two command line switches:
--dry-run
or-n
Prints the paths of the files whose contents would change if the formatter were run normally.
--set-exit-if-changed
Return exit code 1 if there are any formatting changes.
The text was updated successfully, but these errors were encountered: