Skip to content

Commit d9003e6

Browse files
BareninVitalyafilipchristiansen
authored andcommitted
Update git_utils.py: warn on long paths issue on Windows
1 parent 62ae7f0 commit d9003e6

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
@@ -15,6 +15,7 @@
1515

1616
from gitingest.utils.compat_func import removesuffix
1717
from gitingest.utils.exceptions import InvalidGitHubTokenError
18+
from server.server_utils import Colors
1819

1920
if TYPE_CHECKING:
2021
from gitingest.schemas import CloneConfig
@@ -79,13 +80,13 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
7980
async def ensure_git_installed() -> None:
8081
"""Ensure Git is installed and accessible on the system.
8182
82-
On Windows, this also enables support for long file paths via
83-
`git config --system core.longpaths true`.
83+
On Windows, this also checks whether Git is configured to support long file paths.
8484
8585
Raises
8686
------
8787
RuntimeError
8888
If Git is not installed or not accessible, or if enabling long paths fails.
89+
If checking the long path setting fails on Windows.
8990
9091
"""
9192
try:
@@ -95,9 +96,20 @@ async def ensure_git_installed() -> None:
9596
raise RuntimeError(msg) from exc
9697
if sys.platform == "win32":
9798
try:
98-
await run_command("git", "config", "--system", "core.longpaths", "true")
99+
stdout, _ = await run_command("git", "config", "--system", "core.longpaths")
100+
if stdout.decode().strip().lower() != "true":
101+
print(
102+
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
103+
f"due to long file paths:{Colors.END}",
104+
)
105+
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
106+
print(f"{Colors.RED} git config --system core.longpaths true{Colors.END}")
107+
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
99108
except RuntimeError as exc:
100-
msg = "Failed to enable long paths. You may need to run the app as Administrator."
109+
msg = (
110+
"Unable to verify or access Git long path configuration. "
111+
"Run this application as Administrator or configure it manually."
112+
)
101113
raise RuntimeError(msg) from exc
102114

103115

0 commit comments

Comments
 (0)