-
Notifications
You must be signed in to change notification settings - Fork 162
Description
I had a wired encoding bug with some .psm1 Files in the Output/RequiredModules directory if i had to reinclude them into the repository.
After committing those files the content got scrambled with invisible and strange Unicode characters which broke their functionality
This happened sometimes but not always. In my case the issue was with the DSCBuildHelpers Module.
I found out that the issue only happens if the PowerShell File has UTF16le encoding and the file gets treated as text by git.
Currently the .gitattributes file declares everything as text
Line 2 in 29caf18
| * text eol=autocrlf |
and overwrites this for some file extensions.
As far as i understand git uses UTF8 internally and when you commit a file which is configured as text it converts it. After that you'll see the encoding errors.
The git default behaviour for a UTF16le file is to treat it as a binary and that way it stays as it should be.
Other PowerShell files encodings are recognised as text.
Why is this an issue
Sometimes you need a custom version of a required module or you have a niche Azure Dev Ops Server Configuration where you can not use the Azure Dev Ops Artifactory Feed.
Proposal
Remove the everything is text declaration or restrict it to the parts where we are in encoding control like /source/** text eol=autocrlf
Repro Steps
- Create a PowerShell File with UTF16 le encoding.
- Commit the file
- Push the commit
- Git clone the repository to a different location
- Change the file contents at the different location
- Commit and push again
- Pull at the original location