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