Skip to content

Commit af07050

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

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
import sys
@@ -99,20 +98,18 @@ async def ensure_git_installed() -> None:
9998
raise RuntimeError(msg) from exc
10099
if sys.platform == "win32":
101100
try:
102-
if ctypes.windll.shell32.IsUserAnAdmin():
103-
stdout, _ = await run_command("git", "config", "--system", "core.longpaths")
104-
if stdout.decode().strip().lower() == "true":
105-
return
101+
stdout, _ = await run_command("git", "config", "--global", "core.longpaths")
102+
if stdout.decode().strip().lower() != "true":
103+
print(
104+
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
105+
f"due to long file paths:{Colors.END}",
106+
)
107+
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
108+
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
109+
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
106110
except RuntimeError:
107-
# Ignore if checking 'core.longpaths' fails due to lack of administrator rights.
111+
# Ignore if checking 'core.longpaths' fails.
108112
pass
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}")
116113

117114

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

0 commit comments

Comments
 (0)