Current Behavior
If a file was CRLF it will be changed to LF.
Expected Behavior
EOL should not be changed from the original file format
Context / environment
Steps to Reproduce (for bugs)
- Have a repo with a file ending in CRLF
- run e.g. pre-commit hook twincat-leading-tabs-remover on all files
- Check file ending of the file which is now
Suggested Solution
Adapt the hooks to clean the output with something like
with open(filename, "r", encoding="utf-8", newline="") as f:
original = f.read()
eol = "\r\n" if "\r\n" in original else "\n"
fixed = original.replace("\r\n", "\n") # normalize internally
fixed = do_your_thing(fixed)
fixed = fixed.replace("\n", eol) # restore
with open(filename, "w", encoding="utf-8", newline="") as f:
f.write(fixed)
Current Behavior
If a file was CRLF it will be changed to LF.
Expected Behavior
EOL should not be changed from the original file format
Context / environment
Steps to Reproduce (for bugs)
Suggested Solution
Adapt the hooks to clean the output with something like