fix: error out when hermes -w is used outside a git repo
Previously, --worktree printed a yellow warning and continued without isolation, silently defeating the purpose of the flag. Now it prints a clear error message and exits immediately.
This commit is contained in:
parent
b3ea7714f5
commit
1f1caa836a
1 changed files with 6 additions and 1 deletions
7
cli.py
7
cli.py
|
|
@ -429,7 +429,8 @@ def _setup_worktree(repo_root: str = None) -> Optional[Dict[str, str]]:
|
||||||
|
|
||||||
repo_root = repo_root or _git_repo_root()
|
repo_root = repo_root or _git_repo_root()
|
||||||
if not repo_root:
|
if not repo_root:
|
||||||
print("\033[33m⚠ --worktree: not inside a git repository, skipping.\033[0m")
|
print("\033[31m✗ --worktree requires being inside a git repository.\033[0m")
|
||||||
|
print(" cd into your project repo first, then run hermes -w")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
short_id = uuid.uuid4().hex[:8]
|
short_id = uuid.uuid4().hex[:8]
|
||||||
|
|
@ -3810,6 +3811,10 @@ def main(
|
||||||
_active_worktree = wt_info
|
_active_worktree = wt_info
|
||||||
os.environ["TERMINAL_CWD"] = wt_info["path"]
|
os.environ["TERMINAL_CWD"] = wt_info["path"]
|
||||||
atexit.register(_cleanup_worktree, wt_info)
|
atexit.register(_cleanup_worktree, wt_info)
|
||||||
|
else:
|
||||||
|
# Worktree was explicitly requested but setup failed —
|
||||||
|
# don't silently run without isolation.
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
wt_info = None
|
wt_info = None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue