Skip to content

Commit

Permalink
do not exit on minor version mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
akshualy committed Aug 21, 2024
1 parent 2345d14 commit 0df1365
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions alune/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,32 @@ def get_resource_path(relative_path: str | None = None):
return str(path)


def is_version_string_newer(version_one: str, version_two: str):
def is_version_string_newer(version_one: str, version_two: str, ignore_minor_mismatch: bool = False):
"""
Checks if version_one is newer than version_two.
Args:
version_one: The semantic version string to check
version_two: The semantic version string to check against
version_one: The semantic version string to check.
version_two: The semantic version string to check against.
ignore_minor_mismatch: Optional, whether to ignore that the minor version mismatches. Defaults to false.
Returns:
Whether version_one is newer than version_two.
"""
version_one_parts = version_one.split(".")
version_two_parts = version_two.split(".")
version_part_amount = min(len(version_one_parts), len(version_two_parts))

for i in range(min(len(version_one_parts), len(version_two_parts))):
for i in range(version_part_amount):
try:
if int(version_one_parts[i]) > int(version_two_parts[i]):
return True
if int(version_one_parts[i]) <= int(version_two_parts[i]):
continue

if ignore_minor_mismatch and i == version_part_amount - 1:
logger.warning("There is a newer minor version of TFT available. Please update as soon as possible.")
return False

return True
except ValueError:
logger.warning(
f"We could not check version {version_one} against {version_two}. "
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ async def check_phone_preconditions(adb_instance: ADB):
)
play_store_version = installed_version

if helpers.is_version_string_newer(play_store_version, installed_version):
raise_and_exit("A new version of the TFT app is available. Please update to not be locked in queue.")
if helpers.is_version_string_newer(play_store_version, installed_version, ignore_minor_mismatch=True):
raise_and_exit("A new major version of the TFT app is available. An update is required.")

logger.debug("Checking if TFT is active")
if not await adb_instance.is_tft_active():
Expand Down

0 comments on commit 0df1365

Please sign in to comment.