[O] Syntax consistency

This commit is contained in:
Azalea Gui 2023-02-07 18:24:24 -05:00
parent b9eeb068fa
commit 212ac1a3df
No known key found for this signature in database
GPG key ID: E289FAC0DA92DD2B

View file

@ -151,6 +151,7 @@ def get_command_path() -> str:
return cmd_path return cmd_path
def ensure_git_bash() -> Path: def ensure_git_bash() -> Path:
""" """
Ensure git bash installation for windows Ensure git bash installation for windows
@ -163,16 +164,14 @@ def ensure_git_bash() -> Path:
if def_path.is_file(): if def_path.is_file():
return def_path return def_path
# Labda expression that finds out if a command exists # Detect third-party git.exe in path
cmd_exists = lambda x: shutil.which(x) is not None git_exe = shutil.which("git.exe") or shutil.which("git")
if git_exe is not None:
# TEMP-FIX: Make git not hard-coded to being installed "officially" via the git-for-windows installer pth = Path(git_exe).parent
if ( cmd_exists("git.exe") ): if (pth / r'bash.exe').is_file():
pth = Path(shutil.which("git")).parent
if(os.path.isfile(pth / r'bash.exe')):
return pth / r'bash.exe' return pth / r'bash.exe'
elif ( os.path.isfile(pth / r'/bin/bash.exe')): elif (pth / r'bin\bash.exe').is_file():
return pth / r'/bin/bash.exe' return pth / r'bin\bash.exe'
# Find installation in PATH (C:\Program Files\Git\cmd should be in path) # Find installation in PATH (C:\Program Files\Git\cmd should be in path)
pth = (os.environ.get('PATH') or '').lower().split(';') pth = (os.environ.get('PATH') or '').lower().split(';')