clan-cli: Fix clan flakes create inside an already existing git repo

This commit is contained in:
Qubasa
2025-02-17 13:23:31 +07:00
parent 892bd25a3a
commit 52fd912b45
2 changed files with 56 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ from clan_cli.cmd import CmdOut, RunOpts, run
from clan_cli.errors import ClanError
from clan_cli.flake import Flake
from clan_cli.inventory import Inventory, init_inventory
from clan_cli.nix import nix_shell
from clan_cli.nix import nix_metadata, nix_shell
from clan_cli.templates import (
InputPrio,
TemplateName,
@@ -48,6 +48,13 @@ def git_command(directory: Path, *args: str) -> list[str]:
def create_clan(opts: CreateOptions) -> CreateClanResponse:
dest = opts.dest.resolve()
try:
nix_metadata(str(opts.src_flake))
except ClanError:
log.error(f"Found a repository, but it is not a valid flake: {opts.src_flake}")
log.warning("Setting src_flake to None")
opts.src_flake = None
template = get_template(
TemplateName(opts.template_name),
"clan",