We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c21246f commit c881808Copy full SHA for c881808
pre_commit_hooks/end_of_file_fixer.py
@@ -20,9 +20,13 @@ def fix_file(file_obj: IO[bytes]) -> int:
20
last_character = file_obj.read(1)
21
# last_character will be '' for an empty file
22
if last_character not in {LF, CR} and last_character != b'':
23
+ # Check if file uses CRLF endings
24
+ file_obj.seek(0, os.SEEK_SET)
25
+ content = file_obj.read()
26
+ ending = CRLF if CRLF in content else LF
27
# Needs this seek for windows, otherwise IOError
28
file_obj.seek(0, os.SEEK_END)
- file_obj.write(LF)
29
+ file_obj.write(ending)
30
return 1
31
32
while last_character in {LF, CR}:
0 commit comments