Skip to content

Commit 2dc9f13

Browse files
BareninVitalyaix-56h
authored andcommitted
Update git_utils.py: warn on long paths issue on Windows
1 parent 8805b8b commit 2dc9f13

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/gitingest/utils/git_utils.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from gitingest.utils.compat_func import removesuffix
1616
from gitingest.utils.exceptions import InvalidGitHubTokenError
17+
from server.server_utils import Colors
1718

1819
# GitHub Personal-Access tokens (classic + fine-grained).
1920
# - ghp_ / gho_ / ghu_ / ghs_ / ghr_ → 36 alphanumerics
@@ -75,13 +76,13 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
7576
async def ensure_git_installed() -> None:
7677
"""Ensure Git is installed and accessible on the system.
7778
78-
On Windows, this also enables support for long file paths via
79-
`git config --system core.longpaths true`.
79+
On Windows, this also checks whether Git is configured to support long file paths.
8080
8181
Raises
8282
------
8383
RuntimeError
8484
If Git is not installed or not accessible, or if enabling long paths fails.
85+
If checking the long path setting fails on Windows.
8586
8687
"""
8788
try:
@@ -91,9 +92,20 @@ async def ensure_git_installed() -> None:
9192
raise RuntimeError(msg) from exc
9293
if sys.platform == "win32":
9394
try:
94-
await run_command("git", "config", "--system", "core.longpaths", "true")
95+
stdout, _ = await run_command("git", "config", "--system", "core.longpaths")
96+
if stdout.decode().strip().lower() != "true":
97+
print(
98+
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
99+
f"due to long file paths:{Colors.END}",
100+
)
101+
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
102+
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
103+
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
95104
except RuntimeError as exc:
96-
msg = "Failed to enable long paths. You may need to run the app as Administrator."
105+
msg = (
106+
"Unable to verify or access Git long path configuration. "
107+
"Run this application as Administrator or configure it manually."
108+
)
97109
raise RuntimeError(msg) from exc
98110

99111

0 commit comments

Comments
 (0)