Skip to content

Commit e5edc09

Browse files
committed
Improve version comparision logic
1 parent c91868d commit e5edc09

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

supervisor/resolution/evaluations/core_version.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,17 @@ async def evaluate(self) -> bool:
6060
# last known version makes the system supported again, allowing update refresh.
6161
#
6262
# Home Assistant uses CalVer versioning (2024.1, 2024.2, etc.) with monthly releases.
63-
# We consider versions more than 24 releases (approximately 2 years) behind as unsupported.
64-
65-
# Extract year and month from latest version to calculate cutoff
66-
latest_parts = str(latest).split(".")
67-
if len(latest_parts) < 2:
63+
# We consider versions more than 2 years behind as unsupported.
64+
if (
65+
latest.strategy != AwesomeVersionStrategy.CALVER
66+
or latest.year is None
67+
or latest.minor is None
68+
):
6869
return True # Invalid latest version format
6970

70-
latest_year = int(latest_parts[0])
71-
latest_month = int(latest_parts[1])
72-
7371
# Calculate 24 months back from latest version
74-
cutoff_month = latest_month - 24
75-
cutoff_year = latest_year
76-
77-
# Handle year rollover
78-
while cutoff_month <= 0:
79-
cutoff_month += 12
80-
cutoff_year -= 1
72+
cutoff_month = int(latest.minor)
73+
cutoff_year = int(latest.year) - 2
8174

8275
# Create cutoff version
8376
cutoff_version = AwesomeVersion(

0 commit comments

Comments
 (0)