mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Use source instead of URL for repos (#3670)
This commit is contained in:
parent
ccd2c31390
commit
5f9b999a3c
@ -50,7 +50,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration):
|
||||
def repository_urls(self) -> list[str]:
|
||||
"""Return source URL for all git repositories."""
|
||||
return [
|
||||
repository.url
|
||||
repository.source
|
||||
for repository in self.all
|
||||
if repository.type == StoreType.GIT
|
||||
]
|
||||
@ -178,7 +178,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration):
|
||||
|
||||
async def remove_repository(self, repository: Repository, *, persist: bool = True):
|
||||
"""Remove a repository."""
|
||||
if repository.url in BUILTIN_REPOSITORIES:
|
||||
if repository.source in BUILTIN_REPOSITORIES:
|
||||
raise StoreInvalidAddonRepo(
|
||||
"Can't remove built-in repositories!", logger=_LOGGER.error
|
||||
)
|
||||
@ -189,7 +189,7 @@ class StoreManager(CoreSysAttributes, FileConfiguration):
|
||||
logger=_LOGGER.error,
|
||||
)
|
||||
await self.repositories.pop(repository.slug).remove()
|
||||
self._data[ATTR_REPOSITORIES].remove(repository.url)
|
||||
self._data[ATTR_REPOSITORIES].remove(repository.source)
|
||||
self.save_data()
|
||||
|
||||
if persist:
|
||||
|
@ -93,5 +93,5 @@ async def test_api_store_remove_repository(
|
||||
response = await api_client.delete(f"/store/repositories/{repository.slug}")
|
||||
|
||||
assert response.status == 200
|
||||
assert repository.url not in coresys.store.repository_urls
|
||||
assert repository.source not in coresys.store.repository_urls
|
||||
assert repository.slug not in coresys.store.repositories
|
||||
|
@ -46,7 +46,7 @@ async def test_api_supervisor_options_remove_repository(
|
||||
api_client: TestClient, coresys: CoreSys, repository: Repository
|
||||
):
|
||||
"""Test remove a repository via POST /supervisor/options REST API."""
|
||||
assert repository.url in coresys.store.repository_urls
|
||||
assert repository.source in coresys.store.repository_urls
|
||||
assert repository.slug in coresys.store.repositories
|
||||
|
||||
response = await api_client.post(
|
||||
@ -54,7 +54,7 @@ async def test_api_supervisor_options_remove_repository(
|
||||
)
|
||||
|
||||
assert response.status == 200
|
||||
assert repository.url not in coresys.store.repository_urls
|
||||
assert repository.source not in coresys.store.repository_urls
|
||||
assert repository.slug not in coresys.store.repositories
|
||||
|
||||
|
||||
|
@ -194,7 +194,7 @@ async def test_remove_repository(
|
||||
use_update: bool,
|
||||
):
|
||||
"""Test removing a custom repository."""
|
||||
assert repository.url in coresys.store.repository_urls
|
||||
assert repository.source in coresys.store.repository_urls
|
||||
assert repository.slug in coresys.store.repositories
|
||||
|
||||
if use_update:
|
||||
@ -202,7 +202,7 @@ async def test_remove_repository(
|
||||
else:
|
||||
await store_manager.remove_repository(repository)
|
||||
|
||||
assert repository.url not in coresys.store.repository_urls
|
||||
assert repository.source not in coresys.store.repository_urls
|
||||
assert repository.slug not in coresys.addons.store
|
||||
assert repository.slug not in coresys.store.repositories
|
||||
|
||||
@ -261,7 +261,7 @@ async def test_error_adding_duplicate(
|
||||
coresys: CoreSys, store_manager: StoreManager, repository: Repository
|
||||
):
|
||||
"""Test adding a duplicate repository causes an error."""
|
||||
assert repository.url in coresys.store.repository_urls
|
||||
assert repository.source in coresys.store.repository_urls
|
||||
with patch(
|
||||
"supervisor.store.repository.Repository.validate", return_value=True
|
||||
), patch(
|
||||
@ -269,14 +269,14 @@ async def test_error_adding_duplicate(
|
||||
), pytest.raises(
|
||||
StoreError
|
||||
):
|
||||
await store_manager.add_repository(repository.url)
|
||||
await store_manager.add_repository(repository.source)
|
||||
|
||||
|
||||
async def test_add_with_update_repositories(
|
||||
coresys: CoreSys, store_manager: StoreManager, repository: Repository
|
||||
):
|
||||
"""Test adding repositories to existing ones using update."""
|
||||
assert repository.url in coresys.store.repository_urls
|
||||
assert repository.source in coresys.store.repository_urls
|
||||
assert "http://example.com" not in coresys.store.repository_urls
|
||||
|
||||
with patch("supervisor.store.repository.Repository.load", return_value=None), patch(
|
||||
@ -285,5 +285,5 @@ async def test_add_with_update_repositories(
|
||||
), patch("pathlib.Path.exists", return_value=True):
|
||||
await store_manager.update_repositories(["http://example.com"], replace=False)
|
||||
|
||||
assert repository.url in coresys.store.repository_urls
|
||||
assert repository.source in coresys.store.repository_urls
|
||||
assert "http://example.com" in coresys.store.repository_urls
|
||||
|
Loading…
x
Reference in New Issue
Block a user