Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/gitingest/utils/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio
import base64
import re
import sys
from typing import Final
from urllib.parse import urlparse

Expand All @@ -13,6 +14,7 @@

from gitingest.utils.compat_func import removesuffix
from gitingest.utils.exceptions import InvalidGitHubTokenError
from server.server_utils import Colors

# GitHub Personal-Access tokens (classic + fine-grained).
# - ghp_ / gho_ / ghu_ / ghs_ / ghr_ → 36 alphanumerics
Expand Down Expand Up @@ -74,6 +76,8 @@ async def run_command(*args: str) -> tuple[bytes, bytes]:
async def ensure_git_installed() -> None:
"""Ensure Git is installed and accessible on the system.

On Windows, this also checks whether Git is configured to support long file paths.

Raises
------
RuntimeError
Expand All @@ -85,6 +89,20 @@ async def ensure_git_installed() -> None:
except RuntimeError as exc:
msg = "Git is not installed or not accessible. Please install Git first."
raise RuntimeError(msg) from exc
if sys.platform == "win32":
try:
stdout, _ = await run_command("git", "config", "core.longpaths")
if stdout.decode().strip().lower() != "true":
print(
f"{Colors.BROWN}WARN{Colors.END}: {Colors.RED}Git clone may fail on Windows "
f"due to long file paths:{Colors.END}",
)
print(f"{Colors.RED}To avoid this issue, consider enabling long path support with:{Colors.END}")
print(f"{Colors.RED} git config --global core.longpaths true{Colors.END}")
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
except RuntimeError:
# Ignore if checking 'core.longpaths' fails.
pass


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