From ec78d32c5106877eb35131a47bbcb86e887da93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 23 Jan 2022 12:52:41 +0100 Subject: [PATCH] Add DOMAIN_OVERRIDES workaround (#2468) --- custom_components/hacs/repositories/base.py | 9 +++++++-- custom_components/hacs/utils/workarounds.py | 7 +++++++ tests/utils/test_workarounds.py | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 custom_components/hacs/utils/workarounds.py create mode 100644 tests/utils/test_workarounds.py diff --git a/custom_components/hacs/repositories/base.py b/custom_components/hacs/repositories/base.py index d5aa3d8ec15..dad73d55cfa 100644 --- a/custom_components/hacs/repositories/base.py +++ b/custom_components/hacs/repositories/base.py @@ -39,6 +39,7 @@ version_left_higher_then_right, version_to_download, ) +from ..utils.workarounds import DOMAIN_OVERRIDES if TYPE_CHECKING: from ..base import HacsBase @@ -725,8 +726,12 @@ async def remove_local_directory(self) -> None: local_path = self.content.path.local elif self.data.category == "integration": if not self.data.domain: - self.logger.error("%s Missing domain", self) - return False + if domain := DOMAIN_OVERRIDES.get(self.data.full_name): + self.data.domain = domain + self.content.path.local = self.localpath + else: + self.logger.error("%s Missing domain", self) + return False local_path = self.content.path.local else: local_path = self.content.path.local diff --git a/custom_components/hacs/utils/workarounds.py b/custom_components/hacs/utils/workarounds.py new file mode 100644 index 00000000000..b730e3c8dad --- /dev/null +++ b/custom_components/hacs/utils/workarounds.py @@ -0,0 +1,7 @@ +"""Workarounds for issues that should not be fixed.""" + + +DOMAIN_OVERRIDES = { + # https://github.com/hacs/integration/issues/2465 + "custom-components/sensor.custom_aftership": "custom_aftership" +} diff --git a/tests/utils/test_workarounds.py b/tests/utils/test_workarounds.py new file mode 100644 index 00000000000..6440e716981 --- /dev/null +++ b/tests/utils/test_workarounds.py @@ -0,0 +1,6 @@ +from custom_components.hacs.utils.workarounds import DOMAIN_OVERRIDES + + +def test_domain_ovverides() -> None: + assert DOMAIN_OVERRIDES.get("custom-components/sensor.custom_aftership") == "custom_aftership" + assert DOMAIN_OVERRIDES.get("awesome/repo") is None