Update HACS
This commit is contained in:
@@ -18,7 +18,7 @@ from aiogithubapi import (
|
||||
from aiogithubapi.const import BASE_API_URL
|
||||
from aiogithubapi.objects.repository import AIOGitHubAPIRepository
|
||||
import attr
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers import device_registry as dr, issue_registry as ir
|
||||
|
||||
from ..const import DOMAIN
|
||||
from ..enums import ConfigurationType, HacsDispatchEvent, RepositoryFile
|
||||
@@ -734,6 +734,7 @@ class HacsRepository:
|
||||
)
|
||||
|
||||
await self.async_remove_entity_device()
|
||||
ir.async_delete_issue(self.hacs.hass, DOMAIN, f"removed_{self.data.id}")
|
||||
|
||||
async def remove_local_directory(self) -> None:
|
||||
"""Check the local directory."""
|
||||
@@ -993,7 +994,12 @@ class HacsRepository:
|
||||
releases.append(release)
|
||||
return releases
|
||||
|
||||
async def common_update_data(self, ignore_issues: bool = False, force: bool = False) -> None:
|
||||
async def common_update_data(
|
||||
self,
|
||||
ignore_issues: bool = False,
|
||||
force: bool = False,
|
||||
retry=False,
|
||||
) -> None:
|
||||
"""Common update data."""
|
||||
releases = []
|
||||
try:
|
||||
@@ -1072,6 +1078,20 @@ class HacsRepository:
|
||||
for treefile in self.tree:
|
||||
self.treefiles.append(treefile.full_path)
|
||||
except (AIOGitHubAPIException, HacsException) as exception:
|
||||
if (
|
||||
not retry
|
||||
and self.ref is not None
|
||||
and str(exception).startswith("GitHub returned 404")
|
||||
):
|
||||
# Handle tags/branches being deleted.
|
||||
self.data.selected_tag = None
|
||||
self.ref = self.version_to_download()
|
||||
self.logger.warning(
|
||||
"%s Selected version/branch %s has been removed, falling back to default",
|
||||
self.string,
|
||||
self.ref,
|
||||
)
|
||||
return await self.common_update_data(ignore_issues, force, True)
|
||||
if not self.hacs.status.startup and not ignore_issues:
|
||||
self.logger.error("%s %s", self.string, exception)
|
||||
if not ignore_issues:
|
||||
|
||||
@@ -3,8 +3,10 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from homeassistant.helpers.issue_registry import async_create_issue, IssueSeverity
|
||||
from homeassistant.loader import async_get_custom_components
|
||||
|
||||
from ..const import DOMAIN
|
||||
from ..enums import HacsCategory, HacsDispatchEvent, HacsGitHubRepo, RepositoryFile
|
||||
from ..exceptions import AddonRepositoryException, HacsException
|
||||
from ..utils.decode import decode_content
|
||||
@@ -36,13 +38,27 @@ class HacsIntegrationRepository(HacsRepository):
|
||||
|
||||
async def async_post_installation(self):
|
||||
"""Run post installation steps."""
|
||||
self.pending_restart = True
|
||||
if self.data.config_flow:
|
||||
if self.data.full_name != HacsGitHubRepo.INTEGRATION:
|
||||
await self.reload_custom_components()
|
||||
if self.data.first_install:
|
||||
self.pending_restart = False
|
||||
return
|
||||
self.pending_restart = True
|
||||
|
||||
if self.pending_restart and self.hacs.configuration.experimental:
|
||||
self.logger.debug("%s Creating restart_required issue", self.string)
|
||||
async_create_issue(
|
||||
hass=self.hacs.hass,
|
||||
domain=DOMAIN,
|
||||
issue_id=f"restart_required_{self.data.id}_{self.ref}",
|
||||
is_fixable=True,
|
||||
issue_domain=self.data.domain or DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="restart_required",
|
||||
translation_placeholders={
|
||||
"name": self.display_name,
|
||||
},
|
||||
)
|
||||
|
||||
async def validate_repository(self):
|
||||
"""Validate."""
|
||||
|
||||
Reference in New Issue
Block a user