AdRoll / rebar3_format

Erlang Formatter for Rebar3
https://tech.nextroll.com/blog/dev/2020/02/25/erlang-rebar3-format.html
MIT License
109 stars 21 forks source link

Formatter converts CRLF endings to LF #312

Open lukebakken opened 2 years ago

lukebakken commented 2 years ago

Describe the bug

Running rebar3_format on a DOS/Windows text file with CRLF endings will result in LF.

To Reproduce

Run this script on a Windows system with Erlang/OTP and rebar3 installed and in the PATH.

The script clones this repository using core.autocrlf = true, and then runs rebar3 test. This will eventually run the formatter on the files in this project, and you will see that they have been converted to LF endings:

repro.ps1.txt

C:\Users\bakkenl\Temp\rebar3_format [main ≡ +0 ~18 -0 !]
> git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   elvis.config
        modified:   rebar.config
        modified:   src/formatters/default_formatter.erl
        modified:   src/formatters/erlfmt_formatter.erl
        modified:   src/formatters/otp_formatter.erl
        modified:   src/formatters/sr_formatter.erl
        modified:   src/rebar3_ast_formatter.erl
        modified:   src/rebar3_format.app.src
        modified:   src/rebar3_format.erl
        modified:   src/rebar3_format_prv.erl
        modified:   src/rebar3_formatter.erl
        modified:   test/complete_coverage_SUITE.erl
        modified:   test/erlfmt.erl
        modified:   test/erlfmt_formatter_SUITE.erl
        modified:   test/otp_formatter_SUITE.erl
        modified:   test/sr_formatter_SUITE.erl
        modified:   test/steamroller.erl
        modified:   test/test_app_SUITE.erl

Expected behavior

Line endings should not be modified by rebar3_format.

Rebar3 Log

This was generated by adding $env:DEBUG='1' to repro.ps1 and running:

.\repro.ps1 | Tee-Object -Path $HOME\rebar3-debug.log.txt

rebar3-debug.log.txt