-
Notifications
You must be signed in to change notification settings - Fork 460
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
Fun with line endings #22
Conversation
…dapt the corresponding steps
First off - imagine if the world deprecated windows newlines forever! Dagen H was the day that Sweden started driving on the right-hand side of the road rather than the left, and my dream is to see a "Dagen Newline" before the end of my career. But that day isn't today, so thanks for this excellent contribution! I am 100% on board with adding support for I see two issues in the design, both of which are easily addressable.
|
Thanks for your review. And I can comprehend your concerns. Using sanitized Strings for the I like the idea of using a It is not pressing for me. In my day-job-project, Spotless is currently only activated in the build process on my local machine; I would like to enable Spotless globally, but a few months won't matter. PS: For Mac users, Dagen Newline was in 2001 when OS X was released. :-) |
Initially, I've opend this issue as an issue. But unfortunately, I've converted this issue to an pull request, when I've tried to "attach" my branch. An issue would be more suitable for the future proceed. I've just looked if it's possible to do a reconvertion, but it's not. 😔 |
Probably spit a warning that the Spotless config and .gitattributes are in conflict, and ignore these files until the user fixes the conflict.
Yep! In order to support That said, I'm inclined to keep this functionality out of the By keeping the line handling entirely outside of the FormatterSteps, we preserve the illusion of Dagen Newline.
See, it can be done! For a while I think the rumor was that Windows 8 would be Microsoft's Dagen Newline, but it never came to pass. :'(
I agree, so I'm closing this PR and invite you to continue the discussion at #23. |
Just wanted to follow up that Spotless 2.0.0 has full support for .gitattributes, core.lf, and all of git's newline handling. |
Recently I've run into trouble using spotless for a project that uses git.
With the default line ending setting
PLATFORM_NATIVE
spotless works on both Linux and Windows, as long as git checks out the relevant files with CRLF-line-endings under Windows. If someone uses git without its eol-conversion,PLATFORM_NATIVE
won't work on Windows.Setting the line ending to
UNIX
is only an option in cases, where you can ensure the repository is only used on Linux or checked-out as-is on Windows.But even without git, the current line ending setting options lack flexibility: Imagine a project, where CRLFs as well as LFs are used for text files. For example shell-scripts are sometimes forced to use LFs even on Windows.
I like your design of having different formatter steps which can be added to the plugin and configured by a
FormatExtension
😃. So why not doing the same for the EOL-stuff? I see two thinks to do:Removing the normalization from
Formatter
is non-trivial, as all the currently existing steps rely on getting a String normalized to LFs. But it is necessary, as aLineEndingStep
that retrieves already normalized strings doesn't make sense.I'm attaching an implementation proposal. I have splitted it in 5 (hopefully comprehensible) commits. Please let me know what you think. If there is something I should rework, don't hesitate to bring it up. :-)
The proposal is fully backward compatible to the current version. Instead of
PLATFORM_NATIVE
, I would prefere havingDERIVED
as the default, but this kind of API-change should be your decision.This change is