mirror of
https://github.com/cyclotruc/gitingest.git
synced 2026-04-28 10:39:31 +00:00
Update git_utils.py: warn on long paths issue on Windows
This commit is contained in:
parent
5a7f9fafa3
commit
390a591dc5
1 changed files with 16 additions and 4 deletions
|
|
@ -14,6 +14,7 @@ from starlette.status import HTTP_200_OK, HTTP_401_UNAUTHORIZED, HTTP_403_FORBID
|
|||
|
||||
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
|
||||
|
|
@ -75,13 +76,13 @@ 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 enables support for long file paths via
|
||||
`git config --system core.longpaths true`.
|
||||
On Windows, this also checks whether Git is configured to support long file paths.
|
||||
|
||||
Raises
|
||||
------
|
||||
RuntimeError
|
||||
If Git is not installed or not accessible, or if enabling long paths fails.
|
||||
If checking the long path setting fails on Windows.
|
||||
|
||||
"""
|
||||
try:
|
||||
|
|
@ -91,9 +92,20 @@ async def ensure_git_installed() -> None:
|
|||
raise RuntimeError(msg) from exc
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
await run_command("git", "config", "--system", "core.longpaths", "true")
|
||||
stdout, _ = await run_command("git", "config", "--system", "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 --system core.longpaths true{Colors.END}")
|
||||
print(f"{Colors.RED}Note: This command may require administrator privileges.{Colors.END}")
|
||||
except RuntimeError as exc:
|
||||
msg = "Failed to enable long paths. You may need to run the app as Administrator."
|
||||
msg = (
|
||||
"Unable to verify or access Git long path configuration. "
|
||||
"Run this application as Administrator or configure it manually."
|
||||
)
|
||||
raise RuntimeError(msg) from exc
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue