You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use os.path.getsize to get the size of a file. I ran os.path.getsize('configure.bat') on Windows and Ubuntu to see if we get a difference in size. On Windows, configure.bat is 4185 bytes and on Ubuntu, it is 4064 bytes. The size disrepency is due to the line ending differences between Windows and Linux. Text files on Windows end in /r/n, rather than just /n as in Linux. So for every line in a text file on windows, there is an extra byte.
On a freshly cloned repo, typecode/tests/typecode/data/contenttype/size/dir/a.txt is 2 bytes in Ubuntu and 3 bytes in Windows.
I did a quick check and the size is the same for me, given the exact same file (sha1-wise) as an input.
IMHO you must have by tripped by using different checkouts or branches on each OSes :)
@pombredanne so configure.bat is 4064 bytes on windows and ubuntu for you?
On a freshly cloned typecode repo:
C:\Users\Jono\Desktop\typecode-new-new>python
Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.getsize('configure.bat')
4185L
>>> len(open('configure.bat').read())
4064
>>>
I think github is cloning the repo and adding the crlf endings automatically to text files on Windows. The same thing is happening on the azure ci wrt TestContentTypeComplex.test_size
@pombredanne Got around the size detection difference by modifying the windows azure pipeline job template to run git config --global core.autocrlf false before checking out the repo so it doesn't replace the line endings when checking out files. I also had to add a .gitattributes file that sets configure.bat eol=crlf. I found out that the script did not run properly when windows runs a batch script that has LF line endings rather than CRLF.
There are still filetype/mimetype detection differences remaining.
Activity
JonoYang commentedon Oct 27, 2020
We use
os.path.getsizeto get the size of a file. I ranos.path.getsize('configure.bat')on Windows and Ubuntu to see if we get a difference in size. On Windows,configure.batis 4185 bytes and on Ubuntu, it is 4064 bytes. The size disrepency is due to the line ending differences between Windows and Linux. Text files on Windows end in/r/n, rather than just/nas in Linux. So for every line in a text file on windows, there is an extra byte.On a freshly cloned repo,
typecode/tests/typecode/data/contenttype/size/dir/a.txtis 2 bytes in Ubuntu and 3 bytes in Windows.pombredanne commentedon Oct 28, 2020
@JonoYang this difference would be quite a surprise!
pombredanne commentedon Oct 28, 2020
I did a quick check and the size is the same for me, given the exact same file (sha1-wise) as an input.
IMHO you must have by tripped by using different checkouts or branches on each OSes :)
JonoYang commentedon Oct 28, 2020
@pombredanne so
configure.batis 4064 bytes on windows and ubuntu for you?On a freshly cloned typecode repo:
I think github is cloning the repo and adding the crlf endings automatically to text files on Windows. The same thing is happening on the azure ci wrt TestContentTypeComplex.test_size
JonoYang commentedon Oct 29, 2020
@pombredanne Got around the size detection difference by modifying the windows azure pipeline job template to run
git config --global core.autocrlf falsebefore checking out the repo so it doesn't replace the line endings when checking out files. I also had to add a .gitattributes file that setsconfigure.bat eol=crlf. I found out that the script did not run properly when windows runs a batch script that has LF line endings rather than CRLF.There are still filetype/mimetype detection differences remaining.