# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py.

# %% top_export
from pathlib import Path

from repoyard._utils.bisync_helper import SyncSetting
from repoyard.config import get_config
from repoyard import const

def delete_repo(
    config_path: Path,
    repo_full_name: str,
):
    """
    """
    
    # AUTOGENERATED! DO NOT EDIT! File to edit: ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py.
    
    # %% auto 0
    __all__ = ['config', 'repoyard_meta', 'repo_meta']
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py 11
    config = get_config(config_path)
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py 14
    from .._repos import get_repoyard_meta
    repoyard_meta = get_repoyard_meta(config)
    
    if repo_full_name not in repoyard_meta.by_full_name:
        raise ValueError(f"Repo '{repo_full_name}' does not exist.")
    
    repo_meta = repoyard_meta.by_full_name[repo_full_name]
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py 16
    # Delete local repo
    import shutil
    shutil.rmtree(repo_meta.get_local_path(config))
    
    # Delete remote repo
    from .._utils import rclone_purge
    from ..config import StorageType
    if repo_meta.get_storage_location_config(config).storage_type != StorageType.LOCAL:
        rclone_purge(
            config.rclone_config_path,
            source=repo_meta.storage_location,
            source_path=repo_meta.get_remote_path(config),
        )
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/07_delete_repo.pct.py 19
    from .._repos import refresh_repoyard_meta
    refresh_repoyard_meta(config)