Skip to content

fix: detect if git is installed and exit with a clear error - #279

Open
sunasrd-byte wants to merge 1 commit into
Codeplain-ai:mainfrom
sunasrd-byte:fix/133-git-preflight
Open

fix: detect if git is installed and exit with a clear error#279
sunasrd-byte wants to merge 1 commit into
Codeplain-ai:mainfrom
sunasrd-byte:fix/133-git-preflight

Conversation

@sunasrd-byte

Copy link
Copy Markdown
Contributor

Changes:

  • git_preflight.py (new): require_git() reports a clean message and exits 1.
  • plain_modules.py: call require_git() at module scope, immediately above the
    GitPython import.
  • .flake8: E402 per-file ignore for plain_modules.py — require_git() is a
    statement between imports, so every import below it trips E402.
  • tests/test_git_preflight.py (new): subprocess tests asserting a clean
    message, no traceback, and exit 1 for --version, --status, and a render,
    under both a git-less and a broken-git PATH.

Two failure modes are diagnosed separately:

  • git missing — nothing named git on PATH.
  • git present but broken — resolves but cannot run 'git version'. This is the
    normal state on macOS without the Command Line Tools, where /usr/bin/git is
    a stub that exits with an xcrun error. GIT_PYTHON_REFRESH=quiet does not
    suppress this: GitPython only consults that setting for a git it cannot
    find. A PATH lookup alone is therefore insufficient, so require_git runs
    'git version' — matching git_available in install/bash/install.sh.

Verified in python:3.12-slim without git, per the issue's reproduction steps.

Note: GitNotInstalledError is now unraised. Left in place rather than removed
as a drive-by API change.

Closes #133

@sunasrd-byte
sunasrd-byte force-pushed the fix/133-git-preflight branch from c904fe2 to 5db5c0c Compare August 14, 2026 11:58
@NejcS
NejcS self-requested a review August 17, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

*codeplain client should fail if git is not installed

1 participant