AppraiseDev / Appraise

Appraise code used as part of WMT21 human evaluation campaign
BSD 3-Clause "New" or "Revised" License
22 stars 12 forks source link

Inconsistent cross-platform line breaks #111

Open bricksdont opened 1 year ago

bricksdont commented 1 year ago

I noticed that when I fork this repository and then make changes on a Mac machine, that git diff shows ^M characters at the end of lines:

-STATIC_URL = '/static/'
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+FORCE_SCRIPT_NAME = '/service/appraise/'^M
+^M
+STATIC_URL = FORCE_SCRIPT_NAME + '/static/'^M
+STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')^M
+^M

I think this might be because the files are developed on Windows, and have Windows line endings. See for example: https://stackoverflow.com/a/26490990/1987598

Do you know of an easy way to avoid this?

Did you enable automatic line ending normalization with git (https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings?platform=windows)?

bricksdont commented 1 year ago

... after reading some more, could you perhaps use .gitattributes to "set the default behavior, in case people don't have core.autocrlf set"? (https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings?platform=windows#per-repository-settings)

for instance, force CRLF line endings on checkout for Unix users

cfedermann commented 1 year ago

Yeah, good catch.

I develop on several Macs but there is the odd Windows machine in the loop, so autocrlf should be set. I’ll fix this.

On Wed, Apr 26, 2023 at 12:07 PM Mathias Müller @.***> wrote:

... after reading some more, could you perhaps re-normalize the repository to LF and then "set the default behavior, in case people don't have core.autocrlf set"? ( https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings?platform=windows#per-repository-settings )

— Reply to this email directly, view it on GitHub https://github.com/AppraiseDev/Appraise/issues/111#issuecomment-1523154221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACSH2CWMER6PDPUGQHX74LXDDXXBANCNFSM6AAAAAAXMGMB2I . You are receiving this because you are subscribed to this thread.Message ID: @.***>

zouharvi commented 4 months ago

I found these files to have CRLF endings.

$ find . -not -type d -exec file "{}" ";" | grep CRLF
./EvalView/static/EvalView/css/bootstrap-select.min.css: ASCII text, with very long lines (10879), with CRLF line terminators
./static/EvalView/css/bootstrap-select.min.css: ASCII text, with very long lines (10879), with CRLF line terminators
./Dashboard/templates/Dashboard/base.html: HTML document, ASCII text, with very long lines (565), with CRLF line terminators
./Dashboard/models.py: Python script, Unicode text, UTF-8 text executable, with CRLF line terminators
./EvalData/tests/test_models.py: Python script, Unicode text, UTF-8 text executable, with CRLF line terminators
./EvalData/management/commands/CreateDirectAssessmentDataWMT17.py: Python script, ASCII text executable, with CRLF line terminators
./EvalData/management/commands/CreateDirectAssessmentData.py: Python script, ASCII text executable, with CRLF line terminators
./EvalData/management/commands/DumpScoresAndMetadata.py: Python script, ASCII text executable, with CRLF line terminators
./EvalData/models/pairwise_assessment_document.py: Python script, ASCII text executable, with CRLF line terminators
./EvalData/models/direct_assessment_document.py: Python script, ASCII text executable, with CRLF line terminators
./EvalData/models/direct_assessment.py: Python script, ASCII text executable, with CRLF line terminators
./Appraise/utils.py: Python script, ASCII text executable, with CRLF line terminators
./Appraise/settings.py: Python script, ASCII text executable, with CRLF line terminators
./Appraise/urls.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/migrations/0012_auto_20190705_0945.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/migrations/0011_auto_20190705_0942.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/admin.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/management/commands/StartNewCampaign.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/management/commands/ComputeSystemScores.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/models.py: Python script, ASCII text executable, with CRLF line terminators
./Campaign/tests.py: Python script, ASCII text executable, with CRLF line terminators

We could just add "text=lf" to .gitattributes (as per @bricksdont's link).