git_clan_flake_toplevel: gracefully handle permission errors

since this code is used as a default in the cli parser, we should not
crash on OSError because we wouldn't be abe to perform basic tasks such
as --help.
This commit is contained in:
Jörg Thalheim
2025-07-29 14:53:41 +02:00
parent bd6f7b03af
commit 092ac21dcd

View File

@@ -29,9 +29,11 @@ def get_clan_flake_toplevel_or_env() -> Path | None:
def get_clan_flake_toplevel() -> Path | None:
return find_toplevel([".clan-flake", ".git", ".hg", ".svn", "flake.nix"])
try:
return find_toplevel([".clan-flake", ".git", ".hg", ".svn", "flake.nix"])
except OSError:
# We might run clan from a directory that is not readable.
return None
def clan_key_safe(flake_url: str) -> str: