diff --git a/supervisor/store/__init__.py b/supervisor/store/__init__.py index 6a605cd9b..213ce8143 100644 --- a/supervisor/store/__init__.py +++ b/supervisor/store/__init__.py @@ -21,7 +21,6 @@ from .addon import AddonStore from .const import FILE_HASSIO_STORE from .data import StoreData from .repository import Repository -from .types import BuiltinRepository from .validate import SCHEMA_STORE_FILE, ensure_builtin_repositories _LOGGER: logging.Logger = logging.getLogger(__name__) @@ -50,12 +49,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration): @property def repository_urls(self) -> list[str]: """Return source URL for all git repositories.""" - return [ - repository.source - for repository in self.all - if repository.slug - not in {BuiltinRepository.LOCAL.value, BuiltinRepository.CORE.value} - ] + return [repository.source for repository in self.all if repository.is_git_based] def get(self, slug: str) -> Repository: """Return Repository with slug.""" diff --git a/supervisor/store/repository.py b/supervisor/store/repository.py index 115fd409f..c7cf0e91e 100644 --- a/supervisor/store/repository.py +++ b/supervisor/store/repository.py @@ -112,6 +112,11 @@ class Repository(CoreSysAttributes, ABC): def is_builtin(self) -> bool: """Return True if this is a built-in repository.""" + @property + @abstractmethod + def is_git_based(self) -> bool: + """Return True if this is a git-based repository.""" + @abstractmethod async def validate(self) -> bool: """Check if store is valid.""" @@ -158,6 +163,11 @@ class RepositoryGit(Repository, ABC): _git: GitRepo + @property + def is_git_based(self) -> bool: + """Return True if this is a git-based repository.""" + return True + async def load(self) -> None: """Load addon repository.""" await self._git.load() @@ -210,6 +220,11 @@ class RepositoryLocal(RepositoryBuiltin): super().__init__(coresys, BuiltinRepository.LOCAL.value, local_path, slug) self._latest_mtime: float | None = None + @property + def is_git_based(self) -> bool: + """Return True if this is a git-based repository.""" + return False + async def load(self) -> None: """Load addon repository.""" self._latest_mtime, _ = await self.sys_run_in_executor( diff --git a/tests/store/test_store_manager.py b/tests/store/test_store_manager.py index 2e5862f9e..1101f5bae 100644 --- a/tests/store/test_store_manager.py +++ b/tests/store/test_store_manager.py @@ -44,7 +44,7 @@ async def test_default_load(coresys: CoreSys): assert isinstance(store_manager.get("core"), Repository) assert isinstance(store_manager.get("local"), Repository) - assert len(store_manager.repository_urls) == 3 + assert len(store_manager.repository_urls) == 4 assert ( "https://github.com/hassio-addons/repository" in store_manager.repository_urls ) @@ -97,7 +97,7 @@ async def test_load_with_custom_repository(coresys: CoreSys): assert isinstance(store_manager.get("core"), Repository) assert isinstance(store_manager.get("local"), Repository) - assert len(store_manager.repository_urls) == 4 + assert len(store_manager.repository_urls) == 5 assert ( "https://github.com/hassio-addons/repository" in store_manager.repository_urls )