Skip to content

Commit f513938

Browse files
committed
show friendly error when git is not installed
1 parent 74fed2c commit f513938

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

plain2code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from plain2code_events import RenderFailed
2626
from plain2code_exceptions import (
2727
ConflictingRequirements,
28+
GitNotInstalledError,
2829
InvalidAPIKey,
2930
InvalidFridArgument,
3031
MissingAPIKey,
@@ -356,6 +357,7 @@ def main(): # noqa: C901
356357
NetworkConnectionError,
357358
ModuleDoesNotExistError,
358359
UnsupportedResourceType,
360+
GitNotInstalledError,
359361
),
360362
):
361363
exc_info = sys.exc_info()

plain2code_exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ class RenderCancelledError(Exception):
8989
"""Raised when the render is cancelled by the user closing the TUI."""
9090

9191
pass
92+
93+
94+
class GitNotInstalledError(Exception):
95+
"""Raised when git is not installed or not found on PATH."""
96+
97+
pass

plain_modules.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import shutil
66
from functools import cached_property
77

8-
from git.exc import NoSuchPathError
8+
from plain2code_exceptions import GitNotInstalledError, MissingPreviousFunctionalitiesError, ModuleDoesNotExistError
9+
10+
try:
11+
from git.exc import NoSuchPathError
12+
except ImportError:
13+
raise GitNotInstalledError("git is not installed. Please install git and try again.")
914

1015
import git_utils
1116
import plain_file
1217
import plain_spec
1318
from plain2code_console import console
14-
from plain2code_exceptions import MissingPreviousFunctionalitiesError, ModuleDoesNotExistError
1519
from render_machine.implementation_code_helpers import ImplementationCodeHelpers
1620

1721
CODEPLAIN_MEMORY_SUBFOLDER = ".memory"

0 commit comments

Comments
 (0)