Something went wrong. Try again.
Integrated repository, worktree, git stacker, and project manager
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950from __future__ import annotations
from dataclasses import dataclassfrom pathlib import Pathfrom typing import TYPE_CHECKING
from project_manager.paths import Pathsfrom project_manager.render import Column
if TYPE_CHECKING: from project_manager.pool.db import PoolDB
class SlotBusyError(Exception): """Another claimer won the race to record ownership."""
class PoolExhaustedError(Exception): """No free slots under the pool."""
@dataclass(frozen=True)class Slot: repo: str uuid: str path: Path
SLOT_COLUMNS: list[Column] = [ Column("Repo", "repo", style="blue"), Column("UUID", "uuid", style="dim"), Column("Path", "path"),]
def list_slots(paths: Paths, repo: str) -> list[Slot]: pool_dir = paths.pool(repo) if not pool_dir.is_dir(): return [] slots: list[Slot] = [] for entry in sorted(pool_dir.iterdir()): if not entry.is_dir(): continue slots.append(Slot(repo=repo, uuid=entry.name, path=entry)) return slots
def free_slots(paths: Paths, pooldb: PoolDB, repo: str) -> list[Slot]: return [s for s in list_slots(paths, repo) if pooldb.is_free(repo, s.uuid)]