You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug | Any git error other than "not a git repository" makes every command crash with a TypeError #356
get_root_path() (leverage/path.py) runs git rev-parse --show-toplevel. When git fails, it only turns the error into NotARepositoryError if stderr contains fatal: not a git repository. Any other git error makes it return None silently, and the caller crashes:
File "leverage/leverage.py", line 35, in leverage
state.config = conf.load()
File "leverage/conf.py", line 33, in load
root_path = Path(get_root_path())
TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType'
Every command except --help goes through conf.load(), so the whole CLI is unusable, with a traceback that doesn't mention git.
When does git fail with another message?
fatal: detected dubious ownership in repository at ...: the repository belongs to another user (Docker volumes, WSL, shared folders, CI runners). Git refuses to work there until safe.directory is set.
git with a non-English locale: the not a git repository message is translated, so even the "outside a repository" case returns None.
Repro
A fake git that answers like the dubious ownership case:
mkdir -p /tmp/fakegit && cat > /tmp/fakegit/git <<'SH'#!/bin/shecho "fatal: detected dubious ownership in repository at '/work/project'" >&2exit 128SH
chmod +x /tmp/fakegit/git
cd /tmp && PATH=/tmp/fakegit:$PATH leverage tofu plan # TypeError traceback
Proposal
AnyCalledProcessError from git has to end in an error, never None.
Decide what each case shows:
Outside a repository: keep NotARepositoryError. Detect it from the exit code (128) plus git rev-parse --is-inside-work-tree, or force LC_ALL=C for the call, instead of matching the English message.
Any other error: a clear message with git's own stderr (e.g. the safe.directory hint), instead of treating it as "not a repository", which would hide the cause.
Add a test with a fake git on PATH, like the real-git tests in tests/test_root_path.py.
Found while rewriting tests/test_root_path.py (#346, hygiene).
Activity
Enhancement | Root path tests: clear inherited GIT_* variables, force…
Enhancement | Test hygiene: coverage floor, real-git root path tests,…