Skip to content

Commit 89a9912

Browse files
Update git_utils.py: warn on long paths issue on Windows
1 parent c2a73b8 commit 89a9912

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
@@ -9,6 +9,7 @@
99
from urllib.parse import urlparse
1010

1111
from gitingest.utils.exceptions import InvalidGitHubTokenError
12+
from server.server_utils import Colors
1213

1314
GITHUB_PAT_PATTERN = r"^(?:github_pat_|ghp_)[A-Za-z0-9_]{36,}$"
1415

@@ -68,13 +69,13 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
6869
async def ensure_git_installed() -> None:
6970
"""Ensure Git is installed and accessible on the system.
7071
71-
On Windows, this also enables support for long file paths via
72-
`git config --system core.longpaths true`.
72+
On Windows, this also checks whether Git is configured to support long file paths.
7373
7474
Raises
7575
------
7676
RuntimeError
7777
If Git is not installed or not accessible, or if enabling long paths fails.
78+
If checking the long path setting fails on Windows.
7879
7980
"""
8081
try:
@@ -84,9 +85,20 @@ async def ensure_git_installed() -> None:
8485
raise RuntimeError(msg) from exc
8586
if sys.platform == "win32":
8687
try:
87-
await run_command("git", "config", "--system", "core.longpaths", "true")
88+
stdout, _ = await run_command("git", "config", "--system", "core.longpaths")
89+
if stdout.decode().strip().lower() != "true":
90+
print(
91+
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
92+
f"due to long file paths:{Colors.END}",
93+
)
94+
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
95+
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
96+
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
8897
except RuntimeError as exc:
89-
msg = "Failed to enable long paths. You may need to run the app as Administrator."
98+
msg = (
99+
"Unable to verify or access Git long path configuration. "
100+
"Run this application as Administrator or configure it manually."
101+
)
90102
raise RuntimeError(msg) from exc
91103

92104

0 commit comments

Comments
 (0)