Register a repository.
(
self,
repository_full_name: str,
category: HacsCategory,
*,
check: bool = True,
ref: str | None = None,
repository_id: str | None = None,
default: bool = False,
)
| 522 | return None |
| 523 | |
| 524 | async def async_register_repository( |
| 525 | self, |
| 526 | repository_full_name: str, |
| 527 | category: HacsCategory, |
| 528 | *, |
| 529 | check: bool = True, |
| 530 | ref: str | None = None, |
| 531 | repository_id: str | None = None, |
| 532 | default: bool = False, |
| 533 | ) -> None: |
| 534 | """Register a repository.""" |
| 535 | if repository_full_name in self.common.skip: |
| 536 | if repository_full_name != HacsGitHubRepo.INTEGRATION: |
| 537 | raise HacsExpectedException(f"Skipping {repository_full_name}") |
| 538 | |
| 539 | if repository_full_name == "home-assistant/core": |
| 540 | raise HomeAssistantCoreRepositoryException() |
| 541 | |
| 542 | if repository_full_name == "home-assistant/addons" or repository_full_name.startswith( |
| 543 | "hassio-addons/" |
| 544 | ): |
| 545 | raise AddonRepositoryException() |
| 546 | |
| 547 | if category not in REPOSITORY_CLASSES: |
| 548 | self.log.warning( |
| 549 | "%s is not a valid repository category, %s will not be registered.", |
| 550 | category, |
| 551 | repository_full_name, |
| 552 | ) |
| 553 | return |
| 554 | |
| 555 | if (renamed := self.common.renamed_repositories.get(repository_full_name)) is not None: |
| 556 | repository_full_name = renamed |
| 557 | |
| 558 | repository: HacsRepository = REPOSITORY_CLASSES[category](self, repository_full_name) |
| 559 | if check: |
| 560 | try: |
| 561 | await repository.async_registration(ref) |
| 562 | if repository.validate.errors: |
| 563 | self.common.skip.add(repository.data.full_name) |
| 564 | if not self.status.startup: |
| 565 | self.log.error("Validation for %s failed.", repository_full_name) |
| 566 | if self.system.action: |
| 567 | raise HacsException( |
| 568 | f"::error:: Validation for { |
| 569 | repository_full_name} failed." |
| 570 | ) |
| 571 | return repository.validate.errors |
| 572 | if self.system.action: |
| 573 | repository.logger.info("%s Validation completed", repository.string) |
| 574 | else: |
| 575 | repository.logger.info("%s Registration completed", repository.string) |
| 576 | except (HacsRepositoryExistException, HacsRepositoryArchivedException) as exception: |
| 577 | if self.system.generator: |
| 578 | repository.logger.error( |
| 579 | "%s Registration Failed - %s", repository.string, exception |
| 580 | ) |
| 581 | return |
no test coverage detected