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

Add .gitattributes, unify eol/encoding #1

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Apr 5, 2024

Implements a basic .gitattributes to further ensure lf as the repository encoding. Additionally touched a handful of files that weren't using lf/utf8 as expected.

@raulsntos
Copy link
Owner

raulsntos commented Apr 5, 2024

Thanks. Looks like Visual Studio may need the .sln file to use UTF-8 with BOM1. Not sure if this also applies to the .csproj files, and I don't use Visual Studio. Otherwise, the changes look good to me.

Footnotes

  1. https://github.com/dotnet/sdk/issues/8929

@Repiteo
Copy link
Contributor Author

Repiteo commented Apr 5, 2024

Now that you mention it, .csproj and .sln are indeed likely exceptions. To play it safe, I'll set them both up with crlf/utf-8-bom & have .gitattributes/.editorconfig reflect that.

Copy link
Owner

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

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

Can you revert the GUID changes to Godot.sln (as discussed in godotengine/godot#91479 (comment))? Then it should be good to merge, thanks!

@Repiteo
Copy link
Contributor Author

Repiteo commented Jun 3, 2024

Somehow missed that I never got that fix in, whoops. Well, better late than never!

@raulsntos
Copy link
Owner

It looks like the tests are failing on Windows because it expects CRLF endings in the generated .cs files for some reason. I don't know why changing the line endings in the .csproj/.sln would affect this though.

@Repiteo Repiteo force-pushed the gitattributes branch 5 times, most recently from b2e63e5 to e09b5ef Compare June 15, 2024 14:34
@Repiteo
Copy link
Contributor Author

Repiteo commented Jun 15, 2024

The easiest workaround I could find was ensuring the generated files use \n line endings.

@raulsntos
Copy link
Owner

raulsntos commented Jun 15, 2024

That doesn't explain why the tests were passing before. Could it be that .gitattributes determines what line endings the cloned files will have? If so, I guess CI was cloning these files with CRLF before since it was unspecified.

I wonder if we could have the generator tests ignore line endings instead when comparing.

@Repiteo
Copy link
Contributor Author

Repiteo commented Jun 15, 2024

I believe the default checkout behavior for Git on Windows has autocrlf=true, which would make all unspecified files have \r\n eol. Making them explicitly lf has the benefit of ensuring that crlf can't be passed to the repo itself, but it causes weird edge-cases on Windows for some Microsoft tools.

In any case, I applied the changes to the generator tests instead. Now after reading the files it converts the line endings to System.Environment.NewLine, effectively making them ignored when compared. There might be a more efficient way of pulling this off, but it got the job done.

@raulsntos
Copy link
Owner

In any case, I applied the changes to the generator tests instead. Now after reading the files it converts the line endings to System.Environment.NewLine, effectively making them ignored when compared.

That seems like the recommended approach1 so it works for me 👍

Footnotes

  1. https://github.com/dotnet/roslyn-sdk/issues/983#issuecomment-1130623676

@raulsntos raulsntos merged commit 715f5ef into raulsntos:master Jun 15, 2024
3 checks passed
@raulsntos
Copy link
Owner

Thanks!

@Repiteo Repiteo deleted the gitattributes branch June 15, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants