Skip to content

Repository

Repository ManagerLink

sierra.package_manager.repository Link

Repository management for Sierra Package Manager.

Handles adding, removing, and updating GitHub repository sources.

ClassesLink

RepositorySource dataclass Link
Python
RepositorySource(
    name: str,
    url: str,
    branch: str = "main",
    enabled: bool = True,
    priority: int = 10,
)

Represents a package repository source.

AttributesLink
name instance-attribute Link
Python
name: str
url instance-attribute Link
Python
url: str
branch class-attribute instance-attribute Link
Python
branch: str = 'main'
enabled class-attribute instance-attribute Link
Python
enabled: bool = True
priority class-attribute instance-attribute Link
Python
priority: int = 10
FunctionsLink
to_dict Link
Python
to_dict() -> dict[str, typing.Any]

Convert to dictionary.

from_dict classmethod Link
Python
from_dict(data: dict) -> RepositorySource

Create from dictionary.

RepositoryManager Link
Python
RepositoryManager(
    config_dir: Path, logger: UniversalLogger | None = None
)

Manages GitHub repository sources for package discovery.

Handles: - Adding/removing repository sources - Updating package registries
- Caching registry data - Validating repository structure

Initialize repository manager.

PARAMETER DESCRIPTION
config_dir

Directory for storing configuration and cache

TYPE: Path

logger

Logger instance for tracking operations

TYPE: UniversalLogger DEFAULT: None

AttributesLink
logger instance-attribute Link
Python
logger = logger or UniversalLogger('RepositoryManager')
config_dir instance-attribute Link
Python
config_dir = Path(config_dir)
sources_file instance-attribute Link
Python
sources_file = self.config_dir / 'sources.json'
cache_dir instance-attribute Link
Python
cache_dir = self.config_dir / 'cache' / 'registry'
sources instance-attribute Link
Python
sources: list[RepositorySource] = []
FunctionsLink
load_sources Link
Python
load_sources() -> None

Load repository sources from disk.

save_sources Link
Python
save_sources() -> None

Save repository sources to disk.

add_source Link
Python
add_source(
    url: str,
    name: str | None = None,
    branch: str = "main",
    priority: int = 10,
) -> RepositorySource

Add a new repository source.

PARAMETER DESCRIPTION
url

GitHub repository URL

TYPE: str

name

Custom name for the source

TYPE: str DEFAULT: None

branch

Git branch to use

TYPE: str DEFAULT: 'main'

priority

Priority for package resolution (lower = higher priority)

TYPE: int DEFAULT: 10

RETURNS DESCRIPTION
RepositorySource

The created source

RAISES DESCRIPTION
ValueError

If source already exists or URL is invalid

remove_source Link
Python
remove_source(name: str) -> bool

Remove a repository source.

PARAMETER DESCRIPTION
name

Name of the source to remove

TYPE: str

RETURNS DESCRIPTION
bool

True if removed, False if not found

list_sources Link
Python
list_sources() -> list[RepositorySource]

Get all configured sources.

RETURNS DESCRIPTION
list[RepositorySource]

List of repository sources sorted by priority

get_source Link
Python
get_source(name: str) -> RepositorySource | None

Get a specific source by name.

PARAMETER DESCRIPTION
name

Source name

TYPE: str

RETURNS DESCRIPTION
RepositorySource | None

The source if found, None otherwise

update_registry Link
Python
update_registry(
    source_name: str | None = None,
) -> dict[str, int]

Update package registries from sources.

PARAMETER DESCRIPTION
source_name

Update specific source, or all if None

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
dict[str, int]

Map of source name to package count

get_cached_registry Link
Python
get_cached_registry(
    source_name: str,
) -> dict[str, typing.Any] | None

Get cached registry for a source.

PARAMETER DESCRIPTION
source_name

Source name

TYPE: str

RETURNS DESCRIPTION
dict | None

Cached registry data or None if not cached