Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 943d5fa

Browse files
Merge pull request #338 from BareninVitalya/fix/windows-support
Fix/windows support
2 parents e023af3 + 9dfb279 commit 943d5fa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎src/gitingest/utils/git_utils.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import asyncio
66
import base64
77
import re
8+
import sys
89
from typing import Final
910
from urllib.parse import urlparse
1011

@@ -13,6 +14,7 @@
1314

1415
from gitingest.utils.compat_func import removesuffix
1516
from 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]:
7476
async 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

90108
async def check_repo_exists(url: str, token: str | None = None) -> bool:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /