Skip to content

Commit

Permalink
make sure it can find ags4 releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Feb 18, 2024
1 parent 3a2531d commit b2fe654
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/agstoolbox/core/gh/list_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
from agstoolbox.core.version.version_utils import tag_to_version


def is_asset_archive(release_name: str, asset_name: str) -> bool:
nversion = release_name.replace(" ", "").replace("v.", "")
if nversion.startswith('v'):
nversion = nversion[1:]
def is_asset_archive_from_version_and_name(version_str: str, asset_name: str) -> bool:
nversion: str = version_str
is_patch = asset_name.startswith("AGS-" + nversion + "-P")
is_beta = asset_name.startswith("AGS-" + nversion + "-Beta")
is_alpha = asset_name.startswith("AGS-" + nversion + "-Alpha")
is_release_candidate = asset_name.startswith("AGS-" + nversion + "-RC")
if is_patch:
patch = asset_name.split(nversion + "-P")[1].split(".")[0]
Expand All @@ -25,6 +24,10 @@ def is_asset_archive(release_name: str, asset_name: str) -> bool:
beta = asset_name.split(nversion + "-Beta")[1].split(".")[0]
nversion += "-Beta" + beta

if is_alpha:
alpha = asset_name.split(nversion + "-Alpha")[1].split(".")[0]
nversion += "-Alpha" + alpha

if is_release_candidate:
rc = asset_name.split(nversion + "-RC")[1].split(".")[0]
nversion += "-RC" + rc
Expand All @@ -33,6 +36,22 @@ def is_asset_archive(release_name: str, asset_name: str) -> bool:
return asset_name == archive_name


def is_asset_archive(release_name: str, asset_name: str) -> bool:
nversion = release_name.replace(" ", "").replace("v.", "")
if nversion.startswith('v'):
nversion = nversion[1:]

if is_asset_archive_from_version_and_name(nversion, asset_name):
return True

version: Version = tag_to_version(nversion)

if is_asset_archive_from_version_and_name(version.as_str, asset_name):
return True

return is_asset_archive_from_version_and_name(version.as_ags4_str, asset_name)


def parse_releases(response_json) -> list[Release]:
releases = [None] * len(response_json)
count = 0
Expand Down
1 change: 1 addition & 0 deletions src/agstoolbox/core/version/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Version:
as_str: str = None
as_ags4_str: str = None
as_int: int = None
family: str = None
family_as_int: int = None
Expand Down
15 changes: 15 additions & 0 deletions src/agstoolbox/core/version/version_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ def version_str_to_int(version: str) -> int:
return version_as_int


def version_int_to_str(version_as_int: int) -> str:

major_i: int = int(version_as_int/(1000 ** 3)) % 1000
minor_i: int = int(version_as_int/(1000 ** 2)) % 1000
improv_i: int = int(version_as_int/1000) % 1000
patch_i: int = int(version_as_int) % 1000

if major_i <= 3:
version_str = "{}.{}.{}.{}".format(major_i, minor_i, improv_i, patch_i)
else:
version_str = "{}.{:02}.{:02}.{:02}".format(major_i, minor_i, improv_i, patch_i)
return version_str


def family_str_to_int(family: str) -> int:
fam = tag_to_family(family)

Expand Down Expand Up @@ -145,6 +159,7 @@ def tag_to_version(tag: str) -> Version:
v.improv = tag_to_improv(v.as_str)
v.patch = tag_to_patch(v.as_str)
v.as_int = version_str_to_int(v.as_str)
v.as_ags4_str = version_int_to_str(v.as_int)
v.family_as_int = family_str_to_int(v.family)
return v

Expand Down

0 comments on commit b2fe654

Please sign in to comment.