xicri / genshin-langdata

English-Chinese-Japanese translation dataset of the terms in Genshin Impact
https://genshin-dictionary.com
Other
27 stars 13 forks source link

Add .gitattributes to convert crlf to lf #302

Open xicri opened 2 months ago

xicri commented 2 months ago

From https://github.com/xicri/genshin-langdata/issues/189#issuecomment-2360918462

Also, if "git config core.autocrlf" is set to true, you will need to remove the following line from .editorconfig.

end_of_line = lf

I will try to solve this issue by adding .gitattributes with * text=auto eol=lf.

xicri commented 2 months ago

@yasuking0304 I have added the .gitattributes to automatically convert CRLF to LF on the commit. When you have time, can you pull the latest main, run git config --local core.autocrlf true in the project root of genshin-langdata, restore end_of_line = lf into your .editorconfig if you have deleted it, and check if any problems happen?

yasuking0304 commented 2 months ago

There is no problem with MacOS. スクリーンショット 2024-09-22 6 48 59

yasuking0304 commented 2 months ago

On Windows, if "end_of_line = lf" is left, newline conversion will be performed with "git config --local core.autocrlf true" enabled, and a warning will be displayed in tags.json. WS000045_2

yasuking0304 commented 2 months ago

And as you may have noticed, json5 files do not seem to be subject to the "end_of_line = lf" check. So, I think it would be fine to leave "end_of_line = lf" as it is, and if there is anything to add, it should be included in README.md for people who want to participate as contributors on Windows.

xicri commented 2 months ago

Thanks for checking!

Hmm... Looks like .gitattributes does not affect core.autocrlf setting, unfortunately.

Since I can't set gitconfig value like core.autocrlf automatically when the other developers cloned or pulled the genshin-langdata repo, I probably have to write an instruction to run git config [--local] core.autocrlf false in the README as you mentioned. I prefer automation and I don't like this way since it's not smart, but there seems no other better solutions...😖

And as you may have noticed, json5 files do not seem to be subject to the "end_of_line = lf" check.

The red underlines are not by EditorConfig. It only converts on file save, but does not validate like linters. I guess the red underlines are by VSCode's built-in JSON validators for *.json and by ESLint for *.js files. JSON5 is not officially supported by VSCode. I guess that's the reason why the underlines are not shown in *.json5 files.

As I said somewhere in this repo before, I'm considering to convert JSON5 files to TypeScript for better support, so it may be affect after the conversion...

xicri commented 2 months ago

@xicri TODO: write an instruction to disable core.autocrlf on Windows.