44
55import asyncio
66import base64
7+ import ctypes
78import os
89import re
910from pathlib import Path
@@ -98,7 +99,6 @@ async def ensure_git_installed() -> None:
9899 ------
99100 RuntimeError
100101 If Git is not installed or not accessible.
101- If checking the long path setting fails on Windows.
102102
103103 """
104104 try :
@@ -108,21 +108,20 @@ async def ensure_git_installed() -> None:
108108 raise RuntimeError (msg ) from exc
109109 if sys .platform == "win32" :
110110 try :
111- stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
112- if stdout .decode ().strip ().lower () != "true" :
113- print (
114- f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
115- f"due to long file paths:{ Colors .END } " ,
116- )
117- print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
118- print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
119- print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
120- except RuntimeError as exc :
121- msg = (
122- "Unable to verify or access Git long path configuration. "
123- "Run this application as Administrator or configure it manually."
124- )
125- raise RuntimeError (msg ) from exc
111+ if ctypes .windll .shell32 .IsUserAnAdmin ():
112+ stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
113+ if stdout .decode ().strip ().lower () == "true" :
114+ return
115+ except RuntimeError :
116+ # Ignore if checking 'core.longpaths' fails due to lack of administrator rights.
117+ pass
118+ print (
119+ f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
120+ f"due to long file paths:{ Colors .END } " ,
121+ )
122+ print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
123+ print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
124+ print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
126125
127126
128127async def check_repo_exists (url : str , token : str | None = None ) -> bool :
0 commit comments