4
4
5
5
import asyncio
6
6
import base64
7
+ import ctypes
7
8
import os
8
9
import re
9
10
from typing import Final
@@ -94,7 +95,6 @@ async def ensure_git_installed() -> None:
94
95
------
95
96
RuntimeError
96
97
If Git is not installed or not accessible.
97
- If checking the long path setting fails on Windows.
98
98
99
99
"""
100
100
try :
@@ -104,21 +104,20 @@ async def ensure_git_installed() -> None:
104
104
raise RuntimeError (msg ) from exc
105
105
if sys .platform == "win32" :
106
106
try :
107
- stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
108
- if stdout .decode ().strip ().lower () != "true" :
109
- print (
110
- f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
111
- f"due to long file paths:{ Colors .END } " ,
112
- )
113
- print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
114
- print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
115
- print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
116
- except RuntimeError as exc :
117
- msg = (
118
- "Unable to verify or access Git long path configuration. "
119
- "Run this application as Administrator or configure it manually."
120
- )
121
- raise RuntimeError (msg ) from exc
107
+ if ctypes .windll .shell32 .IsUserAnAdmin ():
108
+ stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
109
+ if stdout .decode ().strip ().lower () == "true" :
110
+ return
111
+ except RuntimeError :
112
+ # Ignore if checking 'core.longpaths' fails due to lack of administrator rights.
113
+ pass
114
+ print (
115
+ f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
116
+ f"due to long file paths:{ Colors .END } " ,
117
+ )
118
+ print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
119
+ print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
120
+ print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
122
121
123
122
124
123
async def check_repo_exists (url : str , token : str | None = None ) -> bool :
0 commit comments