99from urllib .parse import urlparse
1010
1111from gitingest .utils .exceptions import InvalidGitHubTokenError
12+ from server .server_utils import Colors
1213
1314GITHUB_PAT_PATTERN = r"^(?:github_pat_|ghp_)[A-Za-z0-9_]{36,}$"
1415
@@ -68,13 +69,13 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
6869async def ensure_git_installed () -> None :
6970 """Ensure Git is installed and accessible on the system.
7071
71- On Windows, this also enables support for long file paths via
72- `git config --system core.longpaths true`.
72+ On Windows, this also checks whether Git is configured to support long file paths.
7373
7474 Raises
7575 ------
7676 RuntimeError
7777 If Git is not installed or not accessible, or if enabling long paths fails.
78+ If checking the long path setting fails on Windows.
7879
7980 """
8081 try :
@@ -84,9 +85,20 @@ async def ensure_git_installed() -> None:
8485 raise RuntimeError (msg ) from exc
8586 if sys .platform == "win32" :
8687 try :
87- await run_command ("git" , "config" , "--system" , "core.longpaths" , "true" )
88+ stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
89+ if stdout .decode ().strip ().lower () != "true" :
90+ print (
91+ f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
92+ f"due to long file paths:{ Colors .END } " ,
93+ )
94+ print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
95+ print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
96+ print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
8897 except RuntimeError as exc :
89- msg = "Failed to enable long paths. You may need to run the app as Administrator."
98+ msg = (
99+ "Unable to verify or access Git long path configuration. "
100+ "Run this application as Administrator or configure it manually."
101+ )
90102 raise RuntimeError (msg ) from exc
91103
92104
0 commit comments