Skip to content

Commit d17770c

Browse files
committed
Use old version comparison as fallback (since new is sooo lame)
1 parent 056d8d3 commit d17770c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION ?= 0.4.1
1+
VERSION ?= 0.4.2
22
CACHE ?= --no-cache=1
33
FULLVERSION ?= ${VERSION}
44
archs ?= arm32v7 amd64 i386 arm64v8 arm32v6

github_release_notifier/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"""
44

55
__all__ = ['parser', 'webhook', 'notifier']
6-
__version__ = '0.4.1'
6+
__version__ = '0.4.2'

github_release_notifier/notifier.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
__DEFAULT_FILE__ = os.getenv('GRN_VERSIONS_FILE', str(Path.home()) + '/.github_release_notifier/versions')
1515

1616

17+
def version_compare(version1: str, version2: str) -> int:
18+
def normalize(v):
19+
return [int(x) for x in re.sub(r'([^.0-9]+)', '', v).split(".")]
20+
21+
return (normalize(version1) > normalize(version2)) - (normalize(version1) < normalize(version2))
22+
23+
1724
def _call_webhook(webhook: str, entry: str, logger: logging.Logger) -> None:
1825
logger.info("Hook call : %s / %s" % (webhook, json.dumps(entry)))
1926
try:
@@ -32,9 +39,7 @@ def run(file: str = __DEFAULT_FILE__) -> dict:
3239
try:
3340
condition = LooseVersion(str(entry['version'])) > LooseVersion(str(get_version(package)))
3441
except TypeError as e:
35-
# https://bugs.python.org/issue14894
36-
# Always consider the version is new in case of buggy comparision
37-
condition = True
42+
condition = version_compare(str(entry['version']), str(get_version(package))) > 0
3843
if condition:
3944
database = _get_database(file)
4045
database[package] = entry['version']

0 commit comments

Comments
 (0)