1515
1616from gitingest .utils .compat_func import removesuffix
1717from gitingest .utils .exceptions import InvalidGitHubTokenError
18+ from server .server_utils import Colors
1819
1920if TYPE_CHECKING :
2021 from gitingest .schemas import CloneConfig
@@ -79,13 +80,13 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
7980async def ensure_git_installed () -> None :
8081 """Ensure Git is installed and accessible on the system.
8182
82- On Windows, this also enables support for long file paths via
83- `git config --system core.longpaths true`.
83+ On Windows, this also checks whether Git is configured to support long file paths.
8484
8585 Raises
8686 ------
8787 RuntimeError
8888 If Git is not installed or not accessible, or if enabling long paths fails.
89+ If checking the long path setting fails on Windows.
8990
9091 """
9192 try :
@@ -95,9 +96,20 @@ async def ensure_git_installed() -> None:
9596 raise RuntimeError (msg ) from exc
9697 if sys .platform == "win32" :
9798 try :
98- await run_command ("git" , "config" , "--system" , "core.longpaths" , "true" )
99+ stdout , _ = await run_command ("git" , "config" , "--system" , "core.longpaths" )
100+ if stdout .decode ().strip ().lower () != "true" :
101+ print (
102+ f"{ Colors .BROWN } WARN{ Colors .END } : { Colors .RED } Git clone may fail on Windows "
103+ f"due to long file paths:{ Colors .END } " ,
104+ )
105+ print (f"{ Colors .RED } To avoid this issue, consider enabling long path support with:{ Colors .END } " )
106+ print (f"{ Colors .RED } git config --system core.longpaths true{ Colors .END } " )
107+ print (f"{ Colors .RED } Note: This command may require administrator privileges.{ Colors .END } " )
99108 except RuntimeError as exc :
100- msg = "Failed to enable long paths. You may need to run the app as Administrator."
109+ msg = (
110+ "Unable to verify or access Git long path configuration. "
111+ "Run this application as Administrator or configure it manually."
112+ )
101113 raise RuntimeError (msg ) from exc
102114
103115
0 commit comments