Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ def pending_update(self) -> bool:
if self.data.installed_commit != self.data.last_commit:
return True
return False
if self.display_version_or_commit == "version":
if (
self.display_version_or_commit == "version"
and self.data.installed_version is not None
):
if (
result := version_left_higher_then_right(
self.display_available_version,
Expand Down
26 changes: 26 additions & 0 deletions tests/repositories/helpers/test_properties.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""HACS Repository Helper properties."""
# pylint: disable=missing-docstring
from awesomeversion import AwesomeVersion
import pytest

from custom_components.hacs.repositories.base import HacsRepository

Expand All @@ -21,8 +22,33 @@ def test_repository_helpers_properties_pending_update(hacs):
repository.data.installed = True
repository.data.default_branch = "main"
repository.data.selected_tag = "main"
repository.data.releases = True
repository.data.last_version = "0.2.0"
assert not repository.pending_update

repository.data.installed_commit = "1"
repository.data.last_commit = "2"
assert repository.pending_update


@pytest.mark.parametrize(
("installed_version", "installed_commit", "pending_update"),
[
(None, "3730b11", True),
(None, "1234567", True),
(None, "abcdef0", True),
("0.1.0", "3730b11", True),
("0.2.0", "3730b11", False),
("0.3.0", "3730b11", False),
],
)
def test_pending_update_with_releases(hacs, installed_version, installed_commit, pending_update):
"""Compare release versions without treating an installed commit as a version."""
repository = HacsRepository(hacs)
repository.data.installed = True
repository.data.installed_version = installed_version
repository.data.installed_commit = installed_commit
repository.data.releases = True
repository.data.last_version = "0.2.0"

assert repository.pending_update is pending_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[0.1.0-3730b11-True]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[0.2.0-3730b11-False]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[0.3.0-3730b11-False]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[None-1234567-True]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[None-3730b11-True]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests/repositories/helpers/test_properties.py::test_pending_update_with_releases[None-abcdef0-True]": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1
}
}