[fix][aur] update check

This commit is contained in:
Vinicius Moreira
2019-10-10 17:48:28 -03:00
parent 593eb96a7e
commit 1de85e2fa4
2 changed files with 33 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ from bauh.gems.arch.model import ArchPackage
URL_PKG_DOWNLOAD = 'https://aur.archlinux.org/{}'
RE_LETTERS = re.compile(r'\.([a-zA-Z]+)-\d+$')
RE_ANY_LETTER = re.compile(r'[a-zA-Z]')
RE_SFX = ('r', 're', 'release')
GA_SFX = ('ga', 'ge')
@@ -74,7 +75,33 @@ class ArchDataMapper:
return nlatest > nversion
return latest_version > version
if not RE_ANY_LETTER.findall(latest_version) and not RE_ANY_LETTER.findall(version):
latest_no_rel = latest_version.split('-')
version_no_rel = version.split('-')
latest_split = latest_no_rel[0].split('.')
version_split = version_no_rel[0].split('.')
for idx in range(len(latest_split)):
if idx < len(version_split):
dif = int(latest_split[idx]) - int(version_split[idx])
if dif > 0:
return True
elif dif < 0:
return False
else:
continue
if len(latest_no_rel) > 1 and len(version_no_rel) > 1:
if not RE_ANY_LETTER.findall(latest_no_rel[1]) and not RE_ANY_LETTER.findall(version_no_rel[1]):
return int(latest_no_rel[1]) > int(version_no_rel[1])
else:
return latest_no_rel[1] > version_no_rel[1]
return False
else:
return latest_version > version
return False