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
improve line separator handling #480
Conversation
Codecov Report
@@ Coverage Diff @@
## main #480 +/- ##
============================================
Coverage 100.00% 100.00%
+ Complexity 794 749 -45
============================================
Files 150 139 -11
Lines 2455 2317 -138
Branches 43 48 +5
============================================
- Hits 2455 2317 -138
Continue to review full report at Codecov.
|
src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/Maven.java
Outdated
Show resolved
Hide resolved
It's now cleaner with @pascalgrimaud Should we add endOfLine in ProjectDTO so the user can force it or leave it null for "automatic" mode? For the moment, it's forced to LF with a TODO. |
src/main/java/tech/jhipster/lite/generator/project/domain/Project.java
Outdated
Show resolved
Hide resolved
7772f17
to
dbd6426
Compare
git patch fails with CRLF, maybe we have to force .patch files to be lf, or definitely force LF for everyone as we'll run into multiple issues with CRLF without bringing value. we can also use the detection to check if we have LF, otherwise inform the user to enforce LF (at least during v0.x) + README. |
I didn't expect you provide a 1st solution so fast!
I agree with this, maybe we should simply force LF for project -> in this case, we should change gitattribute as suggested and all the work here is lost ? (really sad) |
Don't worry, the most important is not lost ;) The code is now cleaner and platform independant, all tests pass and we can reuse detection to ensure LF: it will be better than failing on the git patch, as the error it produces is very hard to understand and can be very frustrating for the user. We really needed to investigate on this windows related stuff anyway. Changing gitattributes is not sufficient, as core.autocrlf is responsible for converting the working copy to crlf and is a global config. We could also check it to be false when runni g on local machine... |
@pblanchardie : similar issue here jhipster/generator-jhipster#17115 |
@pblanchardie : can I merge this? |
You can, but it may need further improvements. |
Ok, so I'll wait and merge when the PR will be ready :-) |
fixing conflicts! |
d26faf8
to
b0d8a68
Compare
git patch now works everywhere when *.patch files are forced to stay with lf |
b0d8a68
to
f33f13d
Compare
I did read and was about to answer as I have some advice about what not to do, but I'll get back to it tomorrow ;) this PR can be merged as-is, more to come in other PR. |
Ok @pblanchardie : I'll merge it tomorrow, as I think I need to use your work in existing code:
|
Detection should be improved to ignore sh, vsproj, bat... that are not relevant because they are forced to lf/crlf, and binary files. Not big deal, planned. |
Huge work, thanks a lot @pblanchardie |
fix #477
Some use of indentation constants were also committed as part of this PR
@pascalgrimaud supporting custom line separators would also required that we ensure applying them when modifying Java files (eg. updateExceptionTranslatorIT).
As LF is widely used in git repos by both Unix and Windows worlds, I'm not sure it's worth the effort after all. Let's re-think about forcing LF for everyone as good-practice. I don't know any advantage of using CRLF in source code, and it should never be used in Git.
Note that .gitattributes still overrides bat, cmd, ps1 and sh but it's not the case in editorconfig and prettierrc.