Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Check git mode also in WSL #512
Conversation
| @@ -21,7 +22,9 @@ def zsplit(s: str) -> List[str]: | |||
|
|
|||
|
|
|||
| def check_executables(paths: List[str]) -> int: | |||
| if sys.platform == 'win32': # pragma: win32 cover | |||
| if ( | |||
| sys.platform == 'win32' or 'microsoft' in platform.uname()[3].lower() | |||
asottile
Aug 17, 2020
Member
can you share an example output here and/or add a test? I don't have access to WSL to verify this change
can you share an example output here and/or add a test? I don't have access to WSL to verify this change
emontnemery
Aug 18, 2020
Author
Should I add a comment in the code with the sample output?
I'm not sure what kind of test to add for this, mock the output of platform.uname() and assert _check_git_filemode is called?
Sample output:
$ python3
Python 3.7.5 (default, Nov 7 2019, 10:50:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.uname()
uname_result(system='Linux', node='DESKTOP-A7438J1', release='4.4.0-19041-Microsoft', version='#1-Microsoft Fri Dec 06 14:06:00 PST 2019', machine='x86_64', processor='x86_64')
>>> platform.uname()[3].lower()
'#1-microsoft fri dec 06 14:06:00 pst 2019'
>>>
Should I add a comment in the code with the sample output?
I'm not sure what kind of test to add for this, mock the output of platform.uname() and assert _check_git_filemode is called?
Sample output:
$ python3
Python 3.7.5 (default, Nov 7 2019, 10:50:52)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.uname()
uname_result(system='Linux', node='DESKTOP-A7438J1', release='4.4.0-19041-Microsoft', version='#1-Microsoft Fri Dec 06 14:06:00 PST 2019', machine='x86_64', processor='x86_64')
>>> platform.uname()[3].lower()
'#1-microsoft fri dec 06 14:06:00 pst 2019'
>>>
asottile
Sep 5, 2020
Member
this check seems much too weak imo
this check seems much too weak imo
|
Why does it seem too weak? |
checking if the string "microsoft" is in the uname doesn't necessarily mean this is WSL |
|
I think it's OK, Microsoft builds their own kernels. Checking uname seems to be the accepted solution, see for example here: https://www.scivision.dev/python-detect-wsl/ |
I can build my own kernel too, that doesn't mean this is ok
just because someone else makes the same mistake doesn't mean we should. the uname is an arbitrary string and not necessarily an indication this is WSL |
|
|
OK, so you're saying it's likely someone else builds their own custom kernel, sets uname to 'Microsoft', and then has the git mode check fail on them? |
|
The comment in the thread you're linking to seems to about distinguishing wsl from wsl2 btw, in both cases it's likely that file modes are not supported. Edit: The best way would be to try to properly detect if file modes are supported though, instead of checking for win32 or trying to detect wsl as I attempt in the PR. |
Extend #480 to check git mode when running under WSL too