5
5
import asyncio
6
6
import base64
7
7
import re
8
+ import sys
8
9
from typing import Final
9
10
from urllib .parse import urlparse
10
11
13
14
14
15
from gitingest .utils .compat_func import removesuffix
15
16
from gitingest .utils .exceptions import InvalidGitHubTokenError
17
+ from server .server_utils import Colors
16
18
17
19
# GitHub Personal-Access tokens (classic + fine-grained).
18
20
# - ghp_ / gho_ / ghu_ / ghs_ / ghr_ → 36 alphanumerics
@@ -74,6 +76,8 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
74
76
async def ensure_git_installed () -> None :
75
77
"""Ensure Git is installed and accessible on the system.
76
78
79
+ On Windows, this also checks whether Git is configured to support long file paths.
80
+
77
81
Raises
78
82
------
79
83
RuntimeError
@@ -85,6 +89,20 @@ async def ensure_git_installed() -> None:
85
89
except RuntimeError as exc :
86
90
msg = "Git is not installed or not accessible. Please install Git first."
87
91
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
88
106
89
107
90
108
async def check_repo_exists (url : str , token : str | None = None ) -> bool :
0 commit comments