Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CRLF for resx files #3471

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Oct 31, 2021

Problem

image

image

We do already have a line break there:

<data name="MainInstallKnownError" xml:space="preserve"><value>If the above message indicates a download error, please try again. Otherwise, please open an issue for us to investigate.
If you suspect a metadata problem: https://github.com/KSP-CKAN/NetKAN/issues/new/choose
If you suspect a bug in the client: https://github.com/KSP-CKAN/CKAN/issues/new/choose</value></data>

Cause

It seems that .resx files are supposed to use CRLF line endings, but we have them as normalized to LF in the repo and OS-specific in the working dir (CRLF when checked out on Windows, LF on Linux and Mac), so it would be LF when we build in an Ubuntu container:

*.resx text

Refresher for .gitattributes usage:

  • text means to treat the matching files as text format. LF will be stored to the server, LF will be used on Linux and Mac, CRLF will be used on Windows.
    • text=auto means to run git's built-in algorithm to check whether each matching file is in text format, then treat it as text if so
  • eol=lf means to use LF everywhere
  • eol=crlf means to use CRLF at checkout on all platforms, and who cares what's on the server because you can't see it

So the resource DLLs are built with LF in them, which Windows sometimes doesn't like when those strings get passed to GUI controls. Especially helpfully, if you check out CKAN on Windows and build it there, git will give you .resx files with CRLF and therefore you will get functionally different resource DLLs and possibly not be able to reproduce the problem!

Changes

Now our .gitattributes file specifies eol=crlf for .resx files. This should make git convert these files' line endings to CRLF at checkout on all platforms, so our resource files will contain CRLF as intended in .NET.

As far as I can tell this does not break anything on Linux/Mono. I ran this:

find . -name \*.resx -print0 | xargs -0 unix2dos
git add --renormalize

... as every tutorial says you should do, and it converted all my local .resx files to CRLF. Nothing was staged, however, and I think that's because these files will still have LF on the server, so auto-normalizing the local files from CRLF to LF in the background results in no change to be committed.

Fixes #2847.
Fixes #3470.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows labels Oct 31, 2021
@HebaruSan HebaruSan requested a review from DasSkelett October 31, 2021 18:41
Copy link
Member

@DasSkelett DasSkelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the solution of setting the endings on checkout, in my experience trying to commit CRLF files and handle them in Git gets pretty messy

@DasSkelett DasSkelett merged commit 35927bc into KSP-CKAN:master Nov 17, 2021
@HebaruSan HebaruSan deleted the fix/resx-newlines branch November 17, 2021 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Localized line breaks missing on Windows [Bug] Missing newlines in Windows GUI
2 participants