Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing repository_object during removal #2478

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,12 @@ async def common_update(self, ignore_issues=False, force=False) -> bool:
return False

# Update last updated
self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0)
if self.repository_object:
self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0)

# Update last available commit
await self.repository_object.set_last_commit()
self.data.last_commit = self.repository_object.last_commit
# Update last available commit
await self.repository_object.set_last_commit()
self.data.last_commit = self.repository_object.last_commit

# Get the content of hacs.json
if RepositoryFile.HACS_JSON in [x.filename for x in self.tree]:
Expand Down Expand Up @@ -909,6 +910,8 @@ def update_filenames(self) -> None:

async def get_tree(self, ref: str):
"""Return the repository tree."""
if self.repository_object is None:
raise HacsException("No repository_object")
try:
tree = await self.repository_object.get_tree(ref)
return tree
Expand All @@ -917,6 +920,8 @@ async def get_tree(self, ref: str):

async def get_releases(self, prerelease=False, returnlimit=5):
"""Return the repository releases."""
if self.repository_object is None:
raise HacsException("No repository_object")
try:
releases = await self.repository_object.get_releases(prerelease, returnlimit)
return releases
Expand Down Expand Up @@ -996,7 +1001,7 @@ async def common_update_data(self, ignore_issues: bool = False, force: bool = Fa
for treefile in self.tree:
self.treefiles.append(treefile.full_path)
except (AIOGitHubAPIException, HacsException) as exception:
if not self.hacs.status.startup:
if not self.hacs.status.startup and not ignore_issues:
self.logger.error("%s %s", self, exception)
if not ignore_issues:
raise HacsException(exception) from None
Expand Down