55import asyncio
66import base64
77import re
8+ import sys
89from typing import Final
910from urllib .parse import urlparse
1011
1314
1415from gitingest .utils .compat_func import removesuffix
1516from gitingest .utils .exceptions import InvalidGitHubTokenError
17+ from server .server_utils import Colors
1618
1719# GitHub Personal-Access tokens (classic + fine-grained).
1820# - ghp_ / gho_ / ghu_ / ghs_ / ghr_ → 36 alphanumerics
@@ -74,6 +76,8 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
7476async def ensure_git_installed () -> None :
7577 """Ensure Git is installed and accessible on the system.
7678
79+ On Windows, this also checks whether Git is configured to support long file paths.
80+
7781 Raises
7882 ------
7983 RuntimeError
@@ -85,6 +89,20 @@ async def ensure_git_installed() -> None:
8589 except RuntimeError as exc :
8690 msg = "Git is not installed or not accessible. Please install Git first."
8791 raise RuntimeError (msg ) from exc
92+ if sys .platform == "win32" :
93+ try :
94+ stdout , _ = await run_command ("git" , "config" , "core.longpaths" )
95+ if stdout .decode ().strip ().lower () != "true" :
96+ print (
97+ f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
98+ f"due to long file paths:{ Colors .END } " ,
99+ )
100+ print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
101+ print (f"{ Colors .RED } git config --global core.longpaths true{ Colors .END } " )
102+ print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
103+ except RuntimeError :
104+ # Ignore if checking 'core.longpaths' fails.
105+ pass
88106
89107
90108async def check_repo_exists (url : str , token : str | None = None ) -> bool :
0 commit comments