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

# %% top_export
from pathlib import Path
import subprocess
import os
from typing import Literal, Any

from repoyard._utils import get_repo_full_name_from_sub_path
from repoyard._utils.bisync_helper import bisync_helper, SyncSetting, Sync_RequiresForce, Sync_Conflict, Sync_Error
from repoyard.config import get_config, StorageType
from repoyard import const

def modify_repometa(
    config_path: Path,
    repo_full_name: str,
    modifications: dict[str, Any] = {},
):
    """
    """
    
    # AUTOGENERATED! DO NOT EDIT! File to edit: ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/04_modify_repometa.pct.py.
    
    # %% auto 0
    __all__ = ['config', 'repoyard_meta', 'repo_meta', 'modified_repo_meta']
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/04_modify_repometa.pct.py 11
    config = get_config(config_path)
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/04_modify_repometa.pct.py 14
    from .._repos import get_repoyard_meta, RepoMeta
    repoyard_meta = get_repoyard_meta(config)
    
    if repo_full_name not in repoyard_meta.by_full_name:
        raise ValueError(f"Repo '{repo_full_name}' not found.")
    
    repo_meta = repoyard_meta.by_full_name[repo_full_name]
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/04_modify_repometa.pct.py 16
    modified_repo_meta = RepoMeta(**{
        **repo_meta.model_dump(),
        **modifications
    })
    
    modified_repo_meta.save(config)
    
    # %% ../../../../../../../../../Users/lukastk/dev/2025-11-09_00__repoyard/pts/mod/cmds/04_modify_repometa.pct.py 18
    from .._repos import refresh_repoyard_meta
    refresh_repoyard_meta(config)