make git optional again

This commit is contained in:
Jörg Thalheim
2023-09-22 16:03:14 +02:00
parent e2cf3c1601
commit e3b2424d9d
4 changed files with 14 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import os
import sys
from pathlib import Path
from typing import Optional
from .errors import ClanError
@@ -9,8 +10,11 @@ def get_clan_flake_toplevel() -> Path:
return find_toplevel([".clan-flake", ".git", ".hg", ".svn", "flake.nix"])
def find_git_repo_root() -> Path:
return find_toplevel([".git"])
def find_git_repo_root() -> Optional[Path]:
try:
return find_toplevel([".git"])
except ClanError:
return None
def find_toplevel(top_level_files: list[str]) -> Path: