chore(api/create_clan): remove unused reponse class

This commit is contained in:
Johannes Kirschbauer
2025-06-09 20:30:20 +02:00
parent 2685db33d7
commit 7a1cab1412

View File

@@ -3,7 +3,7 @@ from dataclasses import dataclass
from pathlib import Path
from clan_lib.api import API
from clan_lib.cmd import CmdOut, RunOpts, run
from clan_lib.cmd import RunOpts, run
from clan_lib.errors import ClanError
from clan_lib.flake import Flake
from clan_lib.nix import nix_command, nix_metadata, nix_shell
@@ -18,15 +18,6 @@ from clan_lib.templates import (
log = logging.getLogger(__name__)
@dataclass
class CreateClanResponse:
flake_update: CmdOut | None = None
git_init: CmdOut | None = None
git_add: CmdOut | None = None
git_config_username: CmdOut | None = None
git_config_email: CmdOut | None = None
@dataclass
class CreateOptions:
dest: Path
@@ -43,7 +34,7 @@ def git_command(directory: Path, *args: str) -> list[str]:
@API.register
def create_clan(opts: CreateOptions) -> CreateClanResponse:
def create_clan(opts: CreateOptions) -> None:
dest = opts.dest.resolve()
if opts.src_flake is not None:
@@ -75,36 +66,28 @@ def create_clan(opts: CreateOptions) -> CreateClanResponse:
copy_from_nixstore(src, dest)
response = CreateClanResponse()
if opts.setup_git:
response.git_init = run(git_command(dest, "init"))
response.git_add = run(git_command(dest, "add", "."))
run(git_command(dest, "init"))
run(git_command(dest, "add", "."))
# check if username is set
has_username = run(
git_command(dest, "config", "user.name"), RunOpts(check=False)
)
response.git_config_username = None
if has_username.returncode != 0:
response.git_config_username = run(
git_command(dest, "config", "user.name", "clan-tool")
)
run(git_command(dest, "config", "user.name", "clan-tool"))
has_username = run(
git_command(dest, "config", "user.email"), RunOpts(check=False)
)
if has_username.returncode != 0:
response.git_config_email = run(
git_command(dest, "config", "user.email", "clan@example.com")
)
run(git_command(dest, "config", "user.email", "clan@example.com"))
if opts.update_clan:
flake_update = run(nix_command(["flake", "update"]), RunOpts(cwd=dest))
response.flake_update = flake_update
run(nix_command(["flake", "update"]), RunOpts(cwd=dest))
if opts.initial:
inventory_store = InventoryStore(flake=Flake(str(opts.dest)))
inventory_store.write(opts.initial, message="Init inventory")
return response
return