Skip to content

Commit d284d75

Browse files
Check core.longpaths using --global instead of --system on Windows
1 parent b683e59 commit d284d75

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/gitingest/utils/git_utils.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import asyncio
66
import base64
7-
import ctypes
87
import os
98
import re
109
from typing import Final
@@ -105,20 +104,18 @@ async def ensure_git_installed() -> None:
105104
raise RuntimeError(msg) from exc
106105
if sys.platform == "win32":
107106
try:
108-
if ctypes.windll.shell32.IsUserAnAdmin():
109-
stdout, _ = await run_command("git", "config", "--system", "core.longpaths")
110-
if stdout.decode().strip().lower() == "true":
111-
return
107+
stdout, _ = await run_command("git", "config", "--global", "core.longpaths")
108+
if stdout.decode().strip().lower() != "true":
109+
print(
110+
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
111+
f"due to long file paths:{Colors.END}",
112+
)
113+
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
114+
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
115+
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
112116
except RuntimeError:
113-
# Ignore if checking 'core.longpaths' fails due to lack of administrator rights.
117+
# Ignore if checking 'core.longpaths' fails.
114118
pass
115-
print(
116-
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
117-
f"due to long file paths:{Colors.END}",
118-
)
119-
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
120-
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
121-
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
122119

123120

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

0 commit comments

Comments
 (0)