Handle CRLF and mixed-ending files#1162
Closed
edobez wants to merge 4 commits intopre-commit:mainfrom
Closed
Conversation
Case is for file using CRLF endings
Added case for which the file has mixed line endings. In this case, default into using LF for end of file line.
Author
|
Refers to discussion in #1078. |
Member
|
reading the whole file into memory defeats the purpose of this hook |
Author
|
File could also be read in chunks. Is the problem reading the whole file in memory or traversing the whole file? A possible solution that doesn't involve reading the whole file (in one way or another) is to detect the ending from the first line and assume that is the "selected" ending for the file. Of course this wouldn't catch the case of mixed endings, but might be good enough. |
Member
|
both |
Author
|
Ok, so what about the solution of not caring about mixed line endings? |
Author
|
I pushed that solution into my branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes for
end-of-file-fixer.Refactor the handling of line endings to support files with CRLF and mixed endings.
In the first case, it will add a CRLF for the last line.
In the second case, it will default to LF for the last line.